blob: 02c566fbf53266b19722b974050d306e813e0cd0 [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
bforbisda1169d2018-10-28 11:27:38 -040020"use strict";
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080021
bforbisda1169d2018-10-28 11:27:38 -040022const helpers = require("./helpers");
23const ttypes = require(`./${helpers.genPath}/ThriftTest_types`);
24const Int64 = require("node-int64");
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080025
26//all Languages in UTF-8
27/*jshint -W100 */
bforbisda1169d2018-10-28 11:27:38 -040028const stringTest = (module.exports.stringTest =
29 "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, " +
30 "Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, " +
31 "Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, " +
32 "বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, " +
33 "Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, " +
34 "Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, " +
35 "Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, " +
36 "Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, " +
37 "Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, " +
38 "Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, " +
39 "Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, " +
40 "ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, " +
41 "Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, " +
42 "Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa " +
43 "Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, مازِرونی, Bahasa " +
44 "Melayu, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪" +
45 "Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, " +
46 "Occitan, Иронау, Papiamentu, Deitsch, Polski, پنجابی, پښتو, " +
47 "Norfuk / Pitkern, Português, Runa Simi, Rumantsch, Romani, Română, " +
48 "Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple " +
49 "English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, " +
50 "Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, " +
51 "Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, " +
52 "Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, " +
53 "Bân-lâm-gú, 粵語");
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080054/*jshint +W100 */
55
bforbisda1169d2018-10-28 11:27:38 -040056const specialCharacters = (module.exports.specialCharacters =
57 'quote: " backslash:' +
58 " forwardslash-escaped: / " +
59 " backspace: \b formfeed: \f newline: \n return: \r tab: " +
60 ' now-all-of-them-together: "\\/\b\n\r\t' +
61 " now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><" +
62 ' char-to-test-json-parsing: ]] "]] \\" }}}{ [[[ ');
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080063
bforbisda1169d2018-10-28 11:27:38 -040064const mapTestInput = (module.exports.mapTestInput = {
65 a: "123",
66 "a b": "with spaces ",
67 same: "same",
68 "0": "numeric key",
69 longValue: stringTest,
70 stringTest: "long key"
71});
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080072
bforbisda1169d2018-10-28 11:27:38 -040073const simple = [
74 ["testVoid", undefined],
75 ["testString", "Test"],
76 ["testString", ""],
77 ["testString", stringTest],
78 ["testString", specialCharacters],
79 ["testBool", true],
80 ["testBool", false],
81 ["testByte", 1],
82 ["testByte", 0],
83 ["testByte", -1],
84 ["testByte", -127],
85 ["testI32", -1],
86 ["testDouble", -5.2098523],
87 ["testDouble", 7.012052175215044],
88 ["testEnum", ttypes.Numberz.ONE],
89 ["testI64", 5],
90 ["testI64", -5],
91 ["testI64", 734359738368],
92 ["testI64", -734359738368],
93 ["testI64", new Int64(new Buffer([0, 0x20, 0, 0, 0, 0, 0, 1]))], // 2^53+1
94 [
95 "testI64",
96 new Int64(new Buffer([0xff, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))
97 ], // -2^53-1
98 ["testTypedef", 69]
99];
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -0800100
bforbisda1169d2018-10-28 11:27:38 -0400101const mapout = {};
102for (let i = 0; i < 5; ++i) {
103 mapout[i] = i - 10;
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -0800104}
105
bforbisda1169d2018-10-28 11:27:38 -0400106const deep = [
107 [
108 "testList",
109 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
110 ]
Randy Abernethy983bf7d2015-10-09 12:28:57 -0700111];
112
bforbisda1169d2018-10-28 11:27:38 -0400113const deepUnordered = [
114 ["testMap", mapout],
115 ["testSet", [1, 2, 3]],
116 ["testStringMap", mapTestInput]
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -0800117];
118
bforbisda1169d2018-10-28 11:27:38 -0400119const out = new ttypes.Xtruct({
120 string_thing: "Zero",
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -0800121 byte_thing: 1,
122 i32_thing: -3,
123 i64_thing: 1000000
124});
125
bforbisda1169d2018-10-28 11:27:38 -0400126const out2 = new ttypes.Xtruct2();
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -0800127out2.byte_thing = 1;
128out2.struct_thing = out;
129out2.i32_thing = 5;
130
bforbisda1169d2018-10-28 11:27:38 -0400131const crazy = new ttypes.Insanity({
132 userMap: { "5": 5, "8": 8 },
133 xtructs: [
134 new ttypes.Xtruct({
135 string_thing: "Goodbye4",
136 byte_thing: 4,
137 i32_thing: 4,
138 i64_thing: 4
139 }),
140 new ttypes.Xtruct({
141 string_thing: "Hello2",
142 byte_thing: 2,
143 i32_thing: 2,
144 i64_thing: 2
145 })
146 ]
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -0800147});
148
bforbisda1169d2018-10-28 11:27:38 -0400149const crazy2 = new ttypes.Insanity({
150 userMap: { "5": 5, "8": 8 },
151 xtructs: [
152 {
153 string_thing: "Goodbye4",
154 byte_thing: 4,
155 i32_thing: 4,
156 i64_thing: 4
157 },
158 {
159 string_thing: "Hello2",
160 byte_thing: 2,
161 i32_thing: 2,
162 i64_thing: 2
163 }
164 ]
Henrique Mendonça15d90422015-06-25 22:31:41 +1000165});
166
bforbisda1169d2018-10-28 11:27:38 -0400167const insanity = {
168 "1": { "2": crazy, "3": crazy },
169 "2": { "6": { userMap: {}, xtructs: [] } }
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -0800170};
171
172module.exports.simple = simple;
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -0800173module.exports.deep = deep;
Randy Abernethy983bf7d2015-10-09 12:28:57 -0700174module.exports.deepUnordered = deepUnordered;
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -0800175
176module.exports.out = out;
177module.exports.out2 = out2;
178module.exports.crazy = crazy;
Henrique Mendonça15d90422015-06-25 22:31:41 +1000179module.exports.crazy2 = crazy2;
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -0800180module.exports.insanity = insanity;