blob: bd66dc49661d8a49fe2f9c49e0910b6a37c9bb81 [file] [log] [blame]
James E. King, III375bfee2017-10-26 00:09:34 -04001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080020'use strict';
21
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080022var ttypes = require('./gen-nodejs/ThriftTest_types');
Nobuaki Sukegawaf56b9072015-11-23 19:38:18 +090023var Int64 = require('node-int64');
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080024
25//all Languages in UTF-8
26/*jshint -W100 */
27var stringTest = module.exports.stringTest = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, " +
28 "Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, " +
29 "Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, " +
30 "বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, " +
31 "Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, " +
32 "Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, " +
33 "Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, " +
34 "Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, " +
35 "Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, " +
36 "Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, " +
37 "Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, " +
38 "ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, " +
39 "Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, " +
40 "Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa " +
41 "Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, مازِرونی, Bahasa " +
42 "Melayu, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪" +
43 "Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, " +
44 "Occitan, Иронау, Papiamentu, Deitsch, Polski, پنجابی, پښتو, " +
45 "Norfuk / Pitkern, Português, Runa Simi, Rumantsch, Romani, Română, " +
46 "Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple " +
47 "English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, " +
48 "Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, " +
49 "Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, " +
50 "Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, " +
51 "Bân-lâm-gú, 粵語";
52/*jshint +W100 */
53
54var specialCharacters = module.exports.specialCharacters = 'quote: \" backslash:' +
55 ' forwardslash-escaped: \/ ' +
56 ' backspace: \b formfeed: \f newline: \n return: \r tab: ' +
57 ' now-all-of-them-together: "\\\/\b\n\r\t' +
58 ' now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><' +
59 ' char-to-test-json-parsing: ]] \"]] \\" }}}{ [[[ ';
60
61var mapTestInput = module.exports.mapTestInput = {
62 "a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key",
63 "longValue":stringTest, stringTest:"long key"
64};
65
66var simple = [
67 ['testVoid', undefined],
68 ['testString', 'Test'],
69 ['testString', ''],
70 ['testString', stringTest],
71 ['testString', specialCharacters],
Nobuaki Sukegawaa649e742015-09-21 13:53:25 +090072 ['testBool', true],
73 ['testBool', false],
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080074 ['testByte', 1],
75 ['testByte', 0],
76 ['testByte', -1],
77 ['testByte', -127],
78 ['testI32', -1],
Randy Abernethyd8187c52015-02-16 01:25:53 -080079 ['testDouble', -5.2098523],
80 ['testDouble', 7.012052175215044],
Nobuaki Sukegawaf56b9072015-11-23 19:38:18 +090081 ['testEnum', ttypes.Numberz.ONE],
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080082 ['testI64', 5],
83 ['testI64', -5],
84 ['testI64', 734359738368],
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080085 ['testI64', -734359738368],
Nobuaki Sukegawaf56b9072015-11-23 19:38:18 +090086 ['testI64', new Int64(new Buffer([0, 0x20, 0, 0, 0, 0, 0, 1]))], // 2^53+1
87 ['testI64', new Int64(
88 new Buffer([0xff, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))], // -2^53-1
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080089 ['testTypedef', 69]
Randy Abernethyd8187c52015-02-16 01:25:53 -080090]
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080091
92var mapout = {};
93for (var i = 0; i < 5; ++i) {
94 mapout[i] = i-10;
95}
96
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080097var deep = [
Randy Abernethy983bf7d2015-10-09 12:28:57 -070098 ['testList', [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]],
99];
100
101var deepUnordered = [
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -0800102 ['testMap', mapout],
103 ['testSet', [1,2,3]],
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -0800104 ['testStringMap', mapTestInput]
105];
106
107var out = new ttypes.Xtruct({
108 string_thing: 'Zero',
109 byte_thing: 1,
110 i32_thing: -3,
111 i64_thing: 1000000
112});
113
114var out2 = new ttypes.Xtruct2();
115out2.byte_thing = 1;
116out2.struct_thing = out;
117out2.i32_thing = 5;
118
119var crazy = new ttypes.Insanity({
120 "userMap":{ "5":5, "8":8 },
121 "xtructs":[new ttypes.Xtruct({
122 "string_thing":"Goodbye4",
123 "byte_thing":4,
124 "i32_thing":4,
125 "i64_thing":4
126 }), new ttypes.Xtruct({
127 "string_thing":"Hello2",
128 "byte_thing":2,
129 "i32_thing":2,
130 "i64_thing":2
131 })]
132});
133
Henrique Mendonça15d90422015-06-25 22:31:41 +1000134var crazy2 = new ttypes.Insanity({
135 "userMap":{ "5":5, "8":8 },
136 "xtructs":[{
137 "string_thing":"Goodbye4",
138 "byte_thing":4,
139 "i32_thing":4,
140 "i64_thing":4
141 }, {
142 "string_thing":"Hello2",
143 "byte_thing":2,
144 "i32_thing":2,
145 "i64_thing":2
146 }]
147});
148
149
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -0800150var insanity = {
151 "1":{ "2": crazy, "3": crazy },
152 "2":{ "6":{ "userMap":{}, "xtructs":[] } }
153};
154
155module.exports.simple = simple;
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -0800156module.exports.deep = deep;
Randy Abernethy983bf7d2015-10-09 12:28:57 -0700157module.exports.deepUnordered = deepUnordered;
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -0800158
159module.exports.out = out;
160module.exports.out2 = out2;
161module.exports.crazy = crazy;
Henrique Mendonça15d90422015-06-25 22:31:41 +1000162module.exports.crazy2 = crazy2;
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -0800163module.exports.insanity = insanity;