|
@@ -0,0 +1,2413 @@
|
|
|
|
|
+using Invercargill;
|
|
|
|
|
+using Invercargill.DataStructures;
|
|
|
|
|
+using Invercargill.Operators;
|
|
|
|
|
+
|
|
|
|
|
+// Value-type test matrix: behaviour of non-reference types (bool, int, uint,
|
|
|
|
|
+// long, ulong, int64?, uint64?, float?, double?, char, uchar, enum) across the
|
|
|
|
|
+// data structures. Cases failing at the time of writing are disabled with a
|
|
|
|
|
+// // BROKEN: comment naming type, structure, operation and symptom.
|
|
|
|
|
+
|
|
|
|
|
+public enum ValueTypeFruit { APPLE, BANANA, CHERRY }
|
|
|
|
|
+
|
|
|
|
|
+void value_type_matrix_bool_tests() {
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/bool/vector", () => {
|
|
|
|
|
+ bool[] items = {true, false, true, false};
|
|
|
|
|
+
|
|
|
|
|
+ var v = new Vector<bool>();
|
|
|
|
|
+ foreach (bool i in items) v.add(i);
|
|
|
|
|
+ assert(v.count() == 4);
|
|
|
|
|
+ assert(v.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ bool got;
|
|
|
|
|
+ assert(v.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ assert(v.to_array().length == 4);
|
|
|
|
|
+ assert(v.to_vector().count() == 4);
|
|
|
|
|
+ assert(v.first_or_default() == items[0]);
|
|
|
|
|
+ assert(v.last_or_default() == items[3]);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/bool/buffer", () => {
|
|
|
|
|
+ bool[] items = {true, false, true, false};
|
|
|
|
|
+
|
|
|
|
|
+ var b = new Buffer<bool>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) b.set((uint)i, items[i]);
|
|
|
|
|
+ assert(b.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ bool got;
|
|
|
|
|
+ assert(b.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/bool/ring_buffer", () => {
|
|
|
|
|
+ bool[] items = {true, false, true, false};
|
|
|
|
|
+
|
|
|
|
|
+ var r = new RingBuffer<bool>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) r.set((uint)i, items[i]);
|
|
|
|
|
+ assert(r.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ bool got;
|
|
|
|
|
+ assert(r.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/bool/series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/bool/series", () => {
|
|
|
|
|
+// bool[] items = {true, false, true, false};
|
|
|
|
|
+//
|
|
|
|
|
+// var s = new Series<bool>();
|
|
|
|
|
+// foreach (bool i in items) s.add(i);
|
|
|
|
|
+// assert(s.count() == 4);
|
|
|
|
|
+// var arr = s.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == items[i]);
|
|
|
|
|
+// assert(s.pop_start() == items[0]);
|
|
|
|
|
+// assert(s.count() == 3);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/bool/dictionary): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/bool/dictionary", () => {
|
|
|
|
|
+// bool[] items = {true, false, true, false};
|
|
|
|
|
+//
|
|
|
|
|
+// var d = new Dictionary<bool, string>();
|
|
|
|
|
+// d.set(items[0], "zero");
|
|
|
|
|
+// d.set(items[1], "one");
|
|
|
|
|
+// assert(d.length == 2);
|
|
|
|
|
+// string got;
|
|
|
|
|
+// assert(d.try_get(items[0], out got) && got == "zero");
|
|
|
|
|
+// assert(d.try_get(items[1], out got) && got == "one");
|
|
|
|
|
+// assert(d.has(items[0]));
|
|
|
|
|
+// assert(!d.has(items[2]));
|
|
|
|
|
+// d.set(items[0], "again");
|
|
|
|
|
+// assert(d.length == 2);
|
|
|
|
|
+// assert(d.try_get(items[0], out got) && got == "again");
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/bool/hash_set): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/bool/hash_set", () => {
|
|
|
|
|
+// bool[] items = {true, false, true, false};
|
|
|
|
|
+//
|
|
|
|
|
+// var hs = new HashSet<bool>();
|
|
|
|
|
+// assert(hs.add(items[0]));
|
|
|
|
|
+// assert(hs.add(items[1]));
|
|
|
|
|
+// assert(!hs.add(items[0]));
|
|
|
|
|
+// assert(hs.length == 2);
|
|
|
|
|
+// assert(hs.has(items[0]));
|
|
|
|
|
+// assert(hs.has(items[1]));
|
|
|
|
|
+// assert(!hs.has(items[2]));
|
|
|
|
|
+// bool found;
|
|
|
|
|
+// assert(hs.try_find(items[1], out found) && found == items[1]);
|
|
|
|
|
+// hs.remove(items[0]);
|
|
|
|
|
+// assert(!hs.has(items[0]));
|
|
|
|
|
+// assert(hs.length == 1);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/bool/fifo", () => {
|
|
|
|
|
+ bool[] items = {true, false, true, false};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Fifo<bool>();
|
|
|
|
|
+ foreach (bool i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[0]);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/bool/lifo", () => {
|
|
|
|
|
+ bool[] items = {true, false, true, false};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Lifo<bool>();
|
|
|
|
|
+ foreach (bool i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[3]);
|
|
|
|
|
+ for (int i = 3; i >= 0; i--) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/bool/enumerable): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/bool/enumerable", () => {
|
|
|
|
|
+// bool[] items = {true, false, true, false};
|
|
|
|
|
+//
|
|
|
|
|
+// var e = Wrap.array(items);
|
|
|
|
|
+// assert(e.count() == 4);
|
|
|
|
|
+// assert(e.select<bool>(i => i).count() == 4);
|
|
|
|
|
+// assert(e.to_array().length == 4);
|
|
|
|
|
+// assert(e.to_vector().count() == 4);
|
|
|
|
|
+// assert(e.first() == items[0]);
|
|
|
|
|
+// assert(e.last() == items[3]);
|
|
|
|
|
+// assert(e.contains(items[2]));
|
|
|
|
|
+// var n = Wrap.array(items).aggregate<int>(0, (acc, i) => acc + 1);
|
|
|
|
|
+// assert(n == 4);
|
|
|
|
|
+// var uniq = Wrap.array(items).distinct().count();
|
|
|
|
|
+// assert(uniq == (items[0] == items[3] ? 3 : 4));
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/bool/priority_queue): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/bool/priority_queue", () => {
|
|
|
|
|
+// bool[] items = {true, false, true, false};
|
|
|
|
|
+// bool[] sorted = {false, false, true, true};
|
|
|
|
|
+//
|
|
|
|
|
+// var q = new PriorityQueue<bool>((a, b) => Operators.comparison<bool>()(a, b));
|
|
|
|
|
+// foreach (bool i in items) q.push(i);
|
|
|
|
|
+// assert(q.count() == 4);
|
|
|
|
|
+// assert(q.peek() == sorted[0]);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(q.pop() == sorted[i]);
|
|
|
|
|
+// assert(q.count() == 0);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/bool/sorted_vector): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/bool/sorted_vector", () => {
|
|
|
|
|
+// bool[] items = {true, false, true, false};
|
|
|
|
|
+// bool[] sorted = {false, false, true, true};
|
|
|
|
|
+//
|
|
|
|
|
+// var sv = new SortedVector<bool>();
|
|
|
|
|
+// foreach (bool i in items) sv.add(i);
|
|
|
|
|
+// assert(sv.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// bool got;
|
|
|
|
|
+// assert(sv.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == sorted[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// var sv2 = new SortedVector<bool>();
|
|
|
|
|
+// sv2.add_all(Wrap.array(items));
|
|
|
|
|
+// assert(sv2.length == 4);
|
|
|
|
|
+// assert(sv2.get(0) == sorted[0]);
|
|
|
|
|
+// var srt = Wrap.array(items).sort(Operators.comparison<bool>()).to_array();
|
|
|
|
|
+// assert(srt.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(srt[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/bool/sorted_series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/bool/sorted_series", () => {
|
|
|
|
|
+// bool[] items = {true, false, true, false};
|
|
|
|
|
+// bool[] sorted = {false, false, true, true};
|
|
|
|
|
+//
|
|
|
|
|
+// var ss = new SortedSeries<bool>();
|
|
|
|
|
+// foreach (bool i in items) ss.add(i);
|
|
|
|
|
+// assert(ss.length == 4);
|
|
|
|
|
+// var arr = ss.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/bool/operators", () => {
|
|
|
|
|
+ bool[] items = {true, false, true, false};
|
|
|
|
|
+
|
|
|
|
|
+ var eq = Operators.equality<bool>();
|
|
|
|
|
+ assert(eq(items[0], items[0]));
|
|
|
|
|
+ assert(!eq(items[0], items[1]));
|
|
|
|
|
+ var st = Operators.stringify<bool>();
|
|
|
|
|
+ assert(st(items[0]) != null && st(items[0]).length > 0);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void value_type_matrix_int_tests() {
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/int/vector", () => {
|
|
|
|
|
+ int[] items = {5, -3, 2147483647, -2147483648};
|
|
|
|
|
+
|
|
|
|
|
+ var v = new Vector<int>();
|
|
|
|
|
+ foreach (int i in items) v.add(i);
|
|
|
|
|
+ assert(v.count() == 4);
|
|
|
|
|
+ assert(v.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ int got;
|
|
|
|
|
+ assert(v.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ assert(v.to_array().length == 4);
|
|
|
|
|
+ assert(v.to_vector().count() == 4);
|
|
|
|
|
+ assert(v.first_or_default() == items[0]);
|
|
|
|
|
+ assert(v.last_or_default() == items[3]);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/int/buffer", () => {
|
|
|
|
|
+ int[] items = {5, -3, 2147483647, -2147483648};
|
|
|
|
|
+
|
|
|
|
|
+ var b = new Buffer<int>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) b.set((uint)i, items[i]);
|
|
|
|
|
+ assert(b.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ int got;
|
|
|
|
|
+ assert(b.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/int/ring_buffer", () => {
|
|
|
|
|
+ int[] items = {5, -3, 2147483647, -2147483648};
|
|
|
|
|
+
|
|
|
|
|
+ var r = new RingBuffer<int>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) r.set((uint)i, items[i]);
|
|
|
|
|
+ assert(r.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ int got;
|
|
|
|
|
+ assert(r.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/int/series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/int/series", () => {
|
|
|
|
|
+// int[] items = {5, -3, 2147483647, -2147483648};
|
|
|
|
|
+//
|
|
|
|
|
+// var s = new Series<int>();
|
|
|
|
|
+// foreach (int i in items) s.add(i);
|
|
|
|
|
+// assert(s.count() == 4);
|
|
|
|
|
+// var arr = s.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == items[i]);
|
|
|
|
|
+// assert(s.pop_start() == items[0]);
|
|
|
|
|
+// assert(s.count() == 3);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/int/dictionary", () => {
|
|
|
|
|
+ int[] items = {5, -3, 2147483647, -2147483648};
|
|
|
|
|
+
|
|
|
|
|
+ var d = new Dictionary<int, string>();
|
|
|
|
|
+ d.set(items[0], "zero");
|
|
|
|
|
+ d.set(items[1], "one");
|
|
|
|
|
+ assert(d.length == 2);
|
|
|
|
|
+ string got;
|
|
|
|
|
+ assert(d.try_get(items[0], out got) && got == "zero");
|
|
|
|
|
+ assert(d.try_get(items[1], out got) && got == "one");
|
|
|
|
|
+ assert(d.has(items[0]));
|
|
|
|
|
+ assert(!d.has(items[2]));
|
|
|
|
|
+ d.set(items[0], "again");
|
|
|
|
|
+ assert(d.length == 2);
|
|
|
|
|
+ assert(d.try_get(items[0], out got) && got == "again");
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/int/hash_set", () => {
|
|
|
|
|
+ int[] items = {5, -3, 2147483647, -2147483648};
|
|
|
|
|
+
|
|
|
|
|
+ var hs = new HashSet<int>();
|
|
|
|
|
+ assert(hs.add(items[0]));
|
|
|
|
|
+ assert(hs.add(items[1]));
|
|
|
|
|
+ assert(!hs.add(items[0]));
|
|
|
|
|
+ assert(hs.length == 2);
|
|
|
|
|
+ assert(hs.has(items[0]));
|
|
|
|
|
+ assert(hs.has(items[1]));
|
|
|
|
|
+ assert(!hs.has(items[2]));
|
|
|
|
|
+ int found;
|
|
|
|
|
+ assert(hs.try_find(items[1], out found) && found == items[1]);
|
|
|
|
|
+ hs.remove(items[0]);
|
|
|
|
|
+ assert(!hs.has(items[0]));
|
|
|
|
|
+ assert(hs.length == 1);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/int/fifo", () => {
|
|
|
|
|
+ int[] items = {5, -3, 2147483647, -2147483648};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Fifo<int>();
|
|
|
|
|
+ foreach (int i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[0]);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/int/lifo", () => {
|
|
|
|
|
+ int[] items = {5, -3, 2147483647, -2147483648};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Lifo<int>();
|
|
|
|
|
+ foreach (int i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[3]);
|
|
|
|
|
+ for (int i = 3; i >= 0; i--) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/int/enumerable", () => {
|
|
|
|
|
+ int[] items = {5, -3, 2147483647, -2147483648};
|
|
|
|
|
+
|
|
|
|
|
+ var e = Wrap.array(items);
|
|
|
|
|
+ assert(e.count() == 4);
|
|
|
|
|
+ assert(e.select<int>(i => i).count() == 4);
|
|
|
|
|
+ assert(e.to_array().length == 4);
|
|
|
|
|
+ assert(e.to_vector().count() == 4);
|
|
|
|
|
+ assert(e.first() == items[0]);
|
|
|
|
|
+ assert(e.last() == items[3]);
|
|
|
|
|
+ assert(e.contains(items[2]));
|
|
|
|
|
+ var n = Wrap.array(items).aggregate<int>(0, (acc, i) => acc + 1);
|
|
|
|
|
+ assert(n == 4);
|
|
|
|
|
+ var uniq = Wrap.array(items).distinct().count();
|
|
|
|
|
+ assert(uniq == (items[0] == items[3] ? 3 : 4));
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/int/priority_queue): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/int/priority_queue", () => {
|
|
|
|
|
+// int[] items = {5, -3, 2147483647, -2147483648};
|
|
|
|
|
+// int[] sorted = {-2147483648, -3, 5, 2147483647};
|
|
|
|
|
+//
|
|
|
|
|
+// var q = new PriorityQueue<int>((a, b) => Operators.comparison<int>()(a, b));
|
|
|
|
|
+// foreach (int i in items) q.push(i);
|
|
|
|
|
+// assert(q.count() == 4);
|
|
|
|
|
+// assert(q.peek() == sorted[0]);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(q.pop() == sorted[i]);
|
|
|
|
|
+// assert(q.count() == 0);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/int/sorted_vector): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/int/sorted_vector", () => {
|
|
|
|
|
+// int[] items = {5, -3, 2147483647, -2147483648};
|
|
|
|
|
+// int[] sorted = {-2147483648, -3, 5, 2147483647};
|
|
|
|
|
+//
|
|
|
|
|
+// var sv = new SortedVector<int>();
|
|
|
|
|
+// foreach (int i in items) sv.add(i);
|
|
|
|
|
+// assert(sv.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// int got;
|
|
|
|
|
+// assert(sv.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == sorted[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// var sv2 = new SortedVector<int>();
|
|
|
|
|
+// sv2.add_all(Wrap.array(items));
|
|
|
|
|
+// assert(sv2.length == 4);
|
|
|
|
|
+// assert(sv2.get(0) == sorted[0]);
|
|
|
|
|
+// var srt = Wrap.array(items).sort(Operators.comparison<int>()).to_array();
|
|
|
|
|
+// assert(srt.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(srt[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/int/sorted_series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/int/sorted_series", () => {
|
|
|
|
|
+// int[] items = {5, -3, 2147483647, -2147483648};
|
|
|
|
|
+// int[] sorted = {-2147483648, -3, 5, 2147483647};
|
|
|
|
|
+//
|
|
|
|
|
+// var ss = new SortedSeries<int>();
|
|
|
|
|
+// foreach (int i in items) ss.add(i);
|
|
|
|
|
+// assert(ss.length == 4);
|
|
|
|
|
+// var arr = ss.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/int/operators", () => {
|
|
|
|
|
+ int[] items = {5, -3, 2147483647, -2147483648};
|
|
|
|
|
+
|
|
|
|
|
+ var eq = Operators.equality<int>();
|
|
|
|
|
+ assert(eq(items[0], items[0]));
|
|
|
|
|
+ assert(!eq(items[0], items[1]));
|
|
|
|
|
+ var st = Operators.stringify<int>();
|
|
|
|
|
+ assert(st(items[0]) != null && st(items[0]).length > 0);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void value_type_matrix_uint_tests() {
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uint/vector", () => {
|
|
|
|
|
+ uint[] items = {5u, 3u, 4000000000u, 0u};
|
|
|
|
|
+
|
|
|
|
|
+ var v = new Vector<uint>();
|
|
|
|
|
+ foreach (uint i in items) v.add(i);
|
|
|
|
|
+ assert(v.count() == 4);
|
|
|
|
|
+ assert(v.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ uint got;
|
|
|
|
|
+ assert(v.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ assert(v.to_array().length == 4);
|
|
|
|
|
+ assert(v.to_vector().count() == 4);
|
|
|
|
|
+ assert(v.first_or_default() == items[0]);
|
|
|
|
|
+ assert(v.last_or_default() == items[3]);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uint/buffer", () => {
|
|
|
|
|
+ uint[] items = {5u, 3u, 4000000000u, 0u};
|
|
|
|
|
+
|
|
|
|
|
+ var b = new Buffer<uint>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) b.set((uint)i, items[i]);
|
|
|
|
|
+ assert(b.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ uint got;
|
|
|
|
|
+ assert(b.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uint/ring_buffer", () => {
|
|
|
|
|
+ uint[] items = {5u, 3u, 4000000000u, 0u};
|
|
|
|
|
+
|
|
|
|
|
+ var r = new RingBuffer<uint>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) r.set((uint)i, items[i]);
|
|
|
|
|
+ assert(r.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ uint got;
|
|
|
|
|
+ assert(r.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uint/series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uint/series", () => {
|
|
|
|
|
+// uint[] items = {5u, 3u, 4000000000u, 0u};
|
|
|
|
|
+//
|
|
|
|
|
+// var s = new Series<uint>();
|
|
|
|
|
+// foreach (uint i in items) s.add(i);
|
|
|
|
|
+// assert(s.count() == 4);
|
|
|
|
|
+// var arr = s.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == items[i]);
|
|
|
|
|
+// assert(s.pop_start() == items[0]);
|
|
|
|
|
+// assert(s.count() == 3);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uint/dictionary", () => {
|
|
|
|
|
+ uint[] items = {5u, 3u, 4000000000u, 0u};
|
|
|
|
|
+
|
|
|
|
|
+ var d = new Dictionary<uint, string>();
|
|
|
|
|
+ d.set(items[0], "zero");
|
|
|
|
|
+ d.set(items[1], "one");
|
|
|
|
|
+ assert(d.length == 2);
|
|
|
|
|
+ string got;
|
|
|
|
|
+ assert(d.try_get(items[0], out got) && got == "zero");
|
|
|
|
|
+ assert(d.try_get(items[1], out got) && got == "one");
|
|
|
|
|
+ assert(d.has(items[0]));
|
|
|
|
|
+ assert(!d.has(items[2]));
|
|
|
|
|
+ d.set(items[0], "again");
|
|
|
|
|
+ assert(d.length == 2);
|
|
|
|
|
+ assert(d.try_get(items[0], out got) && got == "again");
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uint/hash_set", () => {
|
|
|
|
|
+ uint[] items = {5u, 3u, 4000000000u, 0u};
|
|
|
|
|
+
|
|
|
|
|
+ var hs = new HashSet<uint>();
|
|
|
|
|
+ assert(hs.add(items[0]));
|
|
|
|
|
+ assert(hs.add(items[1]));
|
|
|
|
|
+ assert(!hs.add(items[0]));
|
|
|
|
|
+ assert(hs.length == 2);
|
|
|
|
|
+ assert(hs.has(items[0]));
|
|
|
|
|
+ assert(hs.has(items[1]));
|
|
|
|
|
+ assert(!hs.has(items[2]));
|
|
|
|
|
+ uint found;
|
|
|
|
|
+ assert(hs.try_find(items[1], out found) && found == items[1]);
|
|
|
|
|
+ hs.remove(items[0]);
|
|
|
|
|
+ assert(!hs.has(items[0]));
|
|
|
|
|
+ assert(hs.length == 1);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uint/fifo", () => {
|
|
|
|
|
+ uint[] items = {5u, 3u, 4000000000u, 0u};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Fifo<uint>();
|
|
|
|
|
+ foreach (uint i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[0]);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uint/lifo", () => {
|
|
|
|
|
+ uint[] items = {5u, 3u, 4000000000u, 0u};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Lifo<uint>();
|
|
|
|
|
+ foreach (uint i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[3]);
|
|
|
|
|
+ for (int i = 3; i >= 0; i--) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uint/enumerable", () => {
|
|
|
|
|
+ uint[] items = {5u, 3u, 4000000000u, 0u};
|
|
|
|
|
+
|
|
|
|
|
+ var e = Wrap.array(items);
|
|
|
|
|
+ assert(e.count() == 4);
|
|
|
|
|
+ assert(e.select<uint>(i => i).count() == 4);
|
|
|
|
|
+ assert(e.to_array().length == 4);
|
|
|
|
|
+ assert(e.to_vector().count() == 4);
|
|
|
|
|
+ assert(e.first() == items[0]);
|
|
|
|
|
+ assert(e.last() == items[3]);
|
|
|
|
|
+ assert(e.contains(items[2]));
|
|
|
|
|
+ var n = Wrap.array(items).aggregate<int>(0, (acc, i) => acc + 1);
|
|
|
|
|
+ assert(n == 4);
|
|
|
|
|
+ var uniq = Wrap.array(items).distinct().count();
|
|
|
|
|
+ assert(uniq == (items[0] == items[3] ? 3 : 4));
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uint/priority_queue): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uint/priority_queue", () => {
|
|
|
|
|
+// uint[] items = {5u, 3u, 4000000000u, 0u};
|
|
|
|
|
+// uint[] sorted = {0u, 3u, 5u, 4000000000u};
|
|
|
|
|
+//
|
|
|
|
|
+// var q = new PriorityQueue<uint>((a, b) => Operators.comparison<uint>()(a, b));
|
|
|
|
|
+// foreach (uint i in items) q.push(i);
|
|
|
|
|
+// assert(q.count() == 4);
|
|
|
|
|
+// assert(q.peek() == sorted[0]);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(q.pop() == sorted[i]);
|
|
|
|
|
+// assert(q.count() == 0);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uint/sorted_vector): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uint/sorted_vector", () => {
|
|
|
|
|
+// uint[] items = {5u, 3u, 4000000000u, 0u};
|
|
|
|
|
+// uint[] sorted = {0u, 3u, 5u, 4000000000u};
|
|
|
|
|
+//
|
|
|
|
|
+// var sv = new SortedVector<uint>();
|
|
|
|
|
+// foreach (uint i in items) sv.add(i);
|
|
|
|
|
+// assert(sv.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// uint got;
|
|
|
|
|
+// assert(sv.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == sorted[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// var sv2 = new SortedVector<uint>();
|
|
|
|
|
+// sv2.add_all(Wrap.array(items));
|
|
|
|
|
+// assert(sv2.length == 4);
|
|
|
|
|
+// assert(sv2.get(0) == sorted[0]);
|
|
|
|
|
+// var srt = Wrap.array(items).sort(Operators.comparison<uint>()).to_array();
|
|
|
|
|
+// assert(srt.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(srt[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uint/sorted_series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uint/sorted_series", () => {
|
|
|
|
|
+// uint[] items = {5u, 3u, 4000000000u, 0u};
|
|
|
|
|
+// uint[] sorted = {0u, 3u, 5u, 4000000000u};
|
|
|
|
|
+//
|
|
|
|
|
+// var ss = new SortedSeries<uint>();
|
|
|
|
|
+// foreach (uint i in items) ss.add(i);
|
|
|
|
|
+// assert(ss.length == 4);
|
|
|
|
|
+// var arr = ss.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uint/operators", () => {
|
|
|
|
|
+ uint[] items = {5u, 3u, 4000000000u, 0u};
|
|
|
|
|
+
|
|
|
|
|
+ var eq = Operators.equality<uint>();
|
|
|
|
|
+ assert(eq(items[0], items[0]));
|
|
|
|
|
+ assert(!eq(items[0], items[1]));
|
|
|
|
|
+ var st = Operators.stringify<uint>();
|
|
|
|
|
+ assert(st(items[0]) != null && st(items[0]).length > 0);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void value_type_matrix_long_tests() {
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/long/vector", () => {
|
|
|
|
|
+ long[] items = {(long)(5000000000L), (long)(-5000000000L), (long)(9223372036854775807L), (long)(0L)};
|
|
|
|
|
+
|
|
|
|
|
+ var v = new Vector<long>();
|
|
|
|
|
+ foreach (long i in items) v.add(i);
|
|
|
|
|
+ assert(v.count() == 4);
|
|
|
|
|
+ assert(v.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ long got;
|
|
|
|
|
+ assert(v.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ assert(v.to_array().length == 4);
|
|
|
|
|
+ assert(v.to_vector().count() == 4);
|
|
|
|
|
+ assert(v.first_or_default() == items[0]);
|
|
|
|
|
+ assert(v.last_or_default() == items[3]);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/long/buffer", () => {
|
|
|
|
|
+ long[] items = {(long)(5000000000L), (long)(-5000000000L), (long)(9223372036854775807L), (long)(0L)};
|
|
|
|
|
+
|
|
|
|
|
+ var b = new Buffer<long>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) b.set((uint)i, items[i]);
|
|
|
|
|
+ assert(b.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ long got;
|
|
|
|
|
+ assert(b.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/long/ring_buffer", () => {
|
|
|
|
|
+ long[] items = {(long)(5000000000L), (long)(-5000000000L), (long)(9223372036854775807L), (long)(0L)};
|
|
|
|
|
+
|
|
|
|
|
+ var r = new RingBuffer<long>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) r.set((uint)i, items[i]);
|
|
|
|
|
+ assert(r.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ long got;
|
|
|
|
|
+ assert(r.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/long/series", () => {
|
|
|
|
|
+ long[] items = {(long)(5000000000L), (long)(-5000000000L), (long)(9223372036854775807L), (long)(0L)};
|
|
|
|
|
+
|
|
|
|
|
+ var s = new Series<long>();
|
|
|
|
|
+ foreach (long i in items) s.add(i);
|
|
|
|
|
+ assert(s.count() == 4);
|
|
|
|
|
+ var arr = s.to_array();
|
|
|
|
|
+ assert(arr.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(arr[i] == items[i]);
|
|
|
|
|
+ assert(s.pop_start() == items[0]);
|
|
|
|
|
+ assert(s.count() == 3);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/long/dictionary", () => {
|
|
|
|
|
+ long[] items = {(long)(5000000000L), (long)(-5000000000L), (long)(9223372036854775807L), (long)(0L)};
|
|
|
|
|
+
|
|
|
|
|
+ var d = new Dictionary<long, string>();
|
|
|
|
|
+ d.set(items[0], "zero");
|
|
|
|
|
+ d.set(items[1], "one");
|
|
|
|
|
+ assert(d.length == 2);
|
|
|
|
|
+ string got;
|
|
|
|
|
+ assert(d.try_get(items[0], out got) && got == "zero");
|
|
|
|
|
+ assert(d.try_get(items[1], out got) && got == "one");
|
|
|
|
|
+ assert(d.has(items[0]));
|
|
|
|
|
+ assert(!d.has(items[2]));
|
|
|
|
|
+ d.set(items[0], "again");
|
|
|
|
|
+ assert(d.length == 2);
|
|
|
|
|
+ assert(d.try_get(items[0], out got) && got == "again");
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/long/hash_set", () => {
|
|
|
|
|
+ long[] items = {(long)(5000000000L), (long)(-5000000000L), (long)(9223372036854775807L), (long)(0L)};
|
|
|
|
|
+
|
|
|
|
|
+ var hs = new HashSet<long>();
|
|
|
|
|
+ assert(hs.add(items[0]));
|
|
|
|
|
+ assert(hs.add(items[1]));
|
|
|
|
|
+ assert(!hs.add(items[0]));
|
|
|
|
|
+ assert(hs.length == 2);
|
|
|
|
|
+ assert(hs.has(items[0]));
|
|
|
|
|
+ assert(hs.has(items[1]));
|
|
|
|
|
+ assert(!hs.has(items[2]));
|
|
|
|
|
+ long found;
|
|
|
|
|
+ assert(hs.try_find(items[1], out found) && found == items[1]);
|
|
|
|
|
+ hs.remove(items[0]);
|
|
|
|
|
+ assert(!hs.has(items[0]));
|
|
|
|
|
+ assert(hs.length == 1);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/long/fifo", () => {
|
|
|
|
|
+ long[] items = {(long)(5000000000L), (long)(-5000000000L), (long)(9223372036854775807L), (long)(0L)};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Fifo<long>();
|
|
|
|
|
+ foreach (long i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[0]);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/long/lifo", () => {
|
|
|
|
|
+ long[] items = {(long)(5000000000L), (long)(-5000000000L), (long)(9223372036854775807L), (long)(0L)};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Lifo<long>();
|
|
|
|
|
+ foreach (long i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[3]);
|
|
|
|
|
+ for (int i = 3; i >= 0; i--) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/long/enumerable", () => {
|
|
|
|
|
+ long[] items = {(long)(5000000000L), (long)(-5000000000L), (long)(9223372036854775807L), (long)(0L)};
|
|
|
|
|
+
|
|
|
|
|
+ var e = Wrap.array(items);
|
|
|
|
|
+ assert(e.count() == 4);
|
|
|
|
|
+ assert(e.select<long>(i => i).count() == 4);
|
|
|
|
|
+ assert(e.to_array().length == 4);
|
|
|
|
|
+ assert(e.to_vector().count() == 4);
|
|
|
|
|
+ assert(e.first() == items[0]);
|
|
|
|
|
+ assert(e.last() == items[3]);
|
|
|
|
|
+ assert(e.contains(items[2]));
|
|
|
|
|
+ var n = Wrap.array(items).aggregate<int>(0, (acc, i) => acc + 1);
|
|
|
|
|
+ assert(n == 4);
|
|
|
|
|
+ var uniq = Wrap.array(items).distinct().count();
|
|
|
|
|
+ assert(uniq == (items[0] == items[3] ? 3 : 4));
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/long/priority_queue): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/long/priority_queue", () => {
|
|
|
|
|
+// long[] items = {(long)(5000000000L), (long)(-5000000000L), (long)(9223372036854775807L), (long)(0L)};
|
|
|
|
|
+// long[] sorted = {(long)(-5000000000L), (long)(0L), (long)(5000000000L), (long)(9223372036854775807L)};
|
|
|
|
|
+//
|
|
|
|
|
+// var q = new PriorityQueue<long>((a, b) => Operators.comparison<long>()(a, b));
|
|
|
|
|
+// foreach (long i in items) q.push(i);
|
|
|
|
|
+// assert(q.count() == 4);
|
|
|
|
|
+// assert(q.peek() == sorted[0]);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(q.pop() == sorted[i]);
|
|
|
|
|
+// assert(q.count() == 0);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/long/sorted_vector): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/long/sorted_vector", () => {
|
|
|
|
|
+// long[] items = {(long)(5000000000L), (long)(-5000000000L), (long)(9223372036854775807L), (long)(0L)};
|
|
|
|
|
+// long[] sorted = {(long)(-5000000000L), (long)(0L), (long)(5000000000L), (long)(9223372036854775807L)};
|
|
|
|
|
+//
|
|
|
|
|
+// var sv = new SortedVector<long>();
|
|
|
|
|
+// foreach (long i in items) sv.add(i);
|
|
|
|
|
+// assert(sv.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// long got;
|
|
|
|
|
+// assert(sv.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == sorted[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// var sv2 = new SortedVector<long>();
|
|
|
|
|
+// sv2.add_all(Wrap.array(items));
|
|
|
|
|
+// assert(sv2.length == 4);
|
|
|
|
|
+// assert(sv2.get(0) == sorted[0]);
|
|
|
|
|
+// var srt = Wrap.array(items).sort(Operators.comparison<long>()).to_array();
|
|
|
|
|
+// assert(srt.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(srt[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/long/sorted_series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/long/sorted_series", () => {
|
|
|
|
|
+// long[] items = {(long)(5000000000L), (long)(-5000000000L), (long)(9223372036854775807L), (long)(0L)};
|
|
|
|
|
+// long[] sorted = {(long)(-5000000000L), (long)(0L), (long)(5000000000L), (long)(9223372036854775807L)};
|
|
|
|
|
+//
|
|
|
|
|
+// var ss = new SortedSeries<long>();
|
|
|
|
|
+// foreach (long i in items) ss.add(i);
|
|
|
|
|
+// assert(ss.length == 4);
|
|
|
|
|
+// var arr = ss.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/long/operators", () => {
|
|
|
|
|
+ long[] items = {(long)(5000000000L), (long)(-5000000000L), (long)(9223372036854775807L), (long)(0L)};
|
|
|
|
|
+
|
|
|
|
|
+ var eq = Operators.equality<long>();
|
|
|
|
|
+ assert(eq(items[0], items[0]));
|
|
|
|
|
+ assert(!eq(items[0], items[1]));
|
|
|
|
|
+ var st = Operators.stringify<long>();
|
|
|
|
|
+ assert(st(items[0]) != null && st(items[0]).length > 0);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void value_type_matrix_ulong_tests() {
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/ulong/vector", () => {
|
|
|
|
|
+ ulong[] items = {(ulong)(5000000000UL), (ulong)(1UL), (ulong)(0UL), (ulong)(18446744073709551615UL)};
|
|
|
|
|
+
|
|
|
|
|
+ var v = new Vector<ulong>();
|
|
|
|
|
+ foreach (ulong i in items) v.add(i);
|
|
|
|
|
+ assert(v.count() == 4);
|
|
|
|
|
+ assert(v.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ ulong got;
|
|
|
|
|
+ assert(v.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ assert(v.to_array().length == 4);
|
|
|
|
|
+ assert(v.to_vector().count() == 4);
|
|
|
|
|
+ assert(v.first_or_default() == items[0]);
|
|
|
|
|
+ assert(v.last_or_default() == items[3]);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/ulong/buffer", () => {
|
|
|
|
|
+ ulong[] items = {(ulong)(5000000000UL), (ulong)(1UL), (ulong)(0UL), (ulong)(18446744073709551615UL)};
|
|
|
|
|
+
|
|
|
|
|
+ var b = new Buffer<ulong>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) b.set((uint)i, items[i]);
|
|
|
|
|
+ assert(b.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ ulong got;
|
|
|
|
|
+ assert(b.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/ulong/ring_buffer", () => {
|
|
|
|
|
+ ulong[] items = {(ulong)(5000000000UL), (ulong)(1UL), (ulong)(0UL), (ulong)(18446744073709551615UL)};
|
|
|
|
|
+
|
|
|
|
|
+ var r = new RingBuffer<ulong>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) r.set((uint)i, items[i]);
|
|
|
|
|
+ assert(r.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ ulong got;
|
|
|
|
|
+ assert(r.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/ulong/series", () => {
|
|
|
|
|
+ ulong[] items = {(ulong)(5000000000UL), (ulong)(1UL), (ulong)(0UL), (ulong)(18446744073709551615UL)};
|
|
|
|
|
+
|
|
|
|
|
+ var s = new Series<ulong>();
|
|
|
|
|
+ foreach (ulong i in items) s.add(i);
|
|
|
|
|
+ assert(s.count() == 4);
|
|
|
|
|
+ var arr = s.to_array();
|
|
|
|
|
+ assert(arr.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(arr[i] == items[i]);
|
|
|
|
|
+ assert(s.pop_start() == items[0]);
|
|
|
|
|
+ assert(s.count() == 3);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/ulong/dictionary", () => {
|
|
|
|
|
+ ulong[] items = {(ulong)(5000000000UL), (ulong)(1UL), (ulong)(0UL), (ulong)(18446744073709551615UL)};
|
|
|
|
|
+
|
|
|
|
|
+ var d = new Dictionary<ulong, string>();
|
|
|
|
|
+ d.set(items[0], "zero");
|
|
|
|
|
+ d.set(items[1], "one");
|
|
|
|
|
+ assert(d.length == 2);
|
|
|
|
|
+ string got;
|
|
|
|
|
+ assert(d.try_get(items[0], out got) && got == "zero");
|
|
|
|
|
+ assert(d.try_get(items[1], out got) && got == "one");
|
|
|
|
|
+ assert(d.has(items[0]));
|
|
|
|
|
+ assert(!d.has(items[2]));
|
|
|
|
|
+ d.set(items[0], "again");
|
|
|
|
|
+ assert(d.length == 2);
|
|
|
|
|
+ assert(d.try_get(items[0], out got) && got == "again");
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/ulong/hash_set", () => {
|
|
|
|
|
+ ulong[] items = {(ulong)(5000000000UL), (ulong)(1UL), (ulong)(0UL), (ulong)(18446744073709551615UL)};
|
|
|
|
|
+
|
|
|
|
|
+ var hs = new HashSet<ulong>();
|
|
|
|
|
+ assert(hs.add(items[0]));
|
|
|
|
|
+ assert(hs.add(items[1]));
|
|
|
|
|
+ assert(!hs.add(items[0]));
|
|
|
|
|
+ assert(hs.length == 2);
|
|
|
|
|
+ assert(hs.has(items[0]));
|
|
|
|
|
+ assert(hs.has(items[1]));
|
|
|
|
|
+ assert(!hs.has(items[2]));
|
|
|
|
|
+ ulong found;
|
|
|
|
|
+ assert(hs.try_find(items[1], out found) && found == items[1]);
|
|
|
|
|
+ hs.remove(items[0]);
|
|
|
|
|
+ assert(!hs.has(items[0]));
|
|
|
|
|
+ assert(hs.length == 1);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/ulong/fifo", () => {
|
|
|
|
|
+ ulong[] items = {(ulong)(5000000000UL), (ulong)(1UL), (ulong)(0UL), (ulong)(18446744073709551615UL)};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Fifo<ulong>();
|
|
|
|
|
+ foreach (ulong i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[0]);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/ulong/lifo", () => {
|
|
|
|
|
+ ulong[] items = {(ulong)(5000000000UL), (ulong)(1UL), (ulong)(0UL), (ulong)(18446744073709551615UL)};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Lifo<ulong>();
|
|
|
|
|
+ foreach (ulong i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[3]);
|
|
|
|
|
+ for (int i = 3; i >= 0; i--) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/ulong/enumerable", () => {
|
|
|
|
|
+ ulong[] items = {(ulong)(5000000000UL), (ulong)(1UL), (ulong)(0UL), (ulong)(18446744073709551615UL)};
|
|
|
|
|
+
|
|
|
|
|
+ var e = Wrap.array(items);
|
|
|
|
|
+ assert(e.count() == 4);
|
|
|
|
|
+ assert(e.select<ulong>(i => i).count() == 4);
|
|
|
|
|
+ assert(e.to_array().length == 4);
|
|
|
|
|
+ assert(e.to_vector().count() == 4);
|
|
|
|
|
+ assert(e.first() == items[0]);
|
|
|
|
|
+ assert(e.last() == items[3]);
|
|
|
|
|
+ assert(e.contains(items[2]));
|
|
|
|
|
+ var n = Wrap.array(items).aggregate<int>(0, (acc, i) => acc + 1);
|
|
|
|
|
+ assert(n == 4);
|
|
|
|
|
+ var uniq = Wrap.array(items).distinct().count();
|
|
|
|
|
+ assert(uniq == (items[0] == items[3] ? 3 : 4));
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/ulong/priority_queue): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/ulong/priority_queue", () => {
|
|
|
|
|
+// ulong[] items = {(ulong)(5000000000UL), (ulong)(1UL), (ulong)(0UL), (ulong)(18446744073709551615UL)};
|
|
|
|
|
+// ulong[] sorted = {(ulong)(0UL), (ulong)(1UL), (ulong)(5000000000UL), (ulong)(18446744073709551615UL)};
|
|
|
|
|
+//
|
|
|
|
|
+// var q = new PriorityQueue<ulong>((a, b) => Operators.comparison<ulong>()(a, b));
|
|
|
|
|
+// foreach (ulong i in items) q.push(i);
|
|
|
|
|
+// assert(q.count() == 4);
|
|
|
|
|
+// assert(q.peek() == sorted[0]);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(q.pop() == sorted[i]);
|
|
|
|
|
+// assert(q.count() == 0);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/ulong/sorted_vector): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/ulong/sorted_vector", () => {
|
|
|
|
|
+// ulong[] items = {(ulong)(5000000000UL), (ulong)(1UL), (ulong)(0UL), (ulong)(18446744073709551615UL)};
|
|
|
|
|
+// ulong[] sorted = {(ulong)(0UL), (ulong)(1UL), (ulong)(5000000000UL), (ulong)(18446744073709551615UL)};
|
|
|
|
|
+//
|
|
|
|
|
+// var sv = new SortedVector<ulong>();
|
|
|
|
|
+// foreach (ulong i in items) sv.add(i);
|
|
|
|
|
+// assert(sv.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// ulong got;
|
|
|
|
|
+// assert(sv.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == sorted[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// var sv2 = new SortedVector<ulong>();
|
|
|
|
|
+// sv2.add_all(Wrap.array(items));
|
|
|
|
|
+// assert(sv2.length == 4);
|
|
|
|
|
+// assert(sv2.get(0) == sorted[0]);
|
|
|
|
|
+// var srt = Wrap.array(items).sort(Operators.comparison<ulong>()).to_array();
|
|
|
|
|
+// assert(srt.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(srt[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/ulong/sorted_series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/ulong/sorted_series", () => {
|
|
|
|
|
+// ulong[] items = {(ulong)(5000000000UL), (ulong)(1UL), (ulong)(0UL), (ulong)(18446744073709551615UL)};
|
|
|
|
|
+// ulong[] sorted = {(ulong)(0UL), (ulong)(1UL), (ulong)(5000000000UL), (ulong)(18446744073709551615UL)};
|
|
|
|
|
+//
|
|
|
|
|
+// var ss = new SortedSeries<ulong>();
|
|
|
|
|
+// foreach (ulong i in items) ss.add(i);
|
|
|
|
|
+// assert(ss.length == 4);
|
|
|
|
|
+// var arr = ss.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/ulong/operators", () => {
|
|
|
|
|
+ ulong[] items = {(ulong)(5000000000UL), (ulong)(1UL), (ulong)(0UL), (ulong)(18446744073709551615UL)};
|
|
|
|
|
+
|
|
|
|
|
+ var eq = Operators.equality<ulong>();
|
|
|
|
|
+ assert(eq(items[0], items[0]));
|
|
|
|
|
+ assert(!eq(items[0], items[1]));
|
|
|
|
|
+ var st = Operators.stringify<ulong>();
|
|
|
|
|
+ assert(st(items[0]) != null && st(items[0]).length > 0);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void value_type_matrix_int64_tests() {
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/int64/vector): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/int64/vector", () => {
|
|
|
|
|
+// int64?[] items = {5000000000L, -5000000000L, 9223372036854775807L, 0L};
|
|
|
|
|
+//
|
|
|
|
|
+// var v = new Vector<int64?>();
|
|
|
|
|
+// foreach (int64? i in items) v.add(i);
|
|
|
|
|
+// assert(v.count() == 4);
|
|
|
|
|
+// assert(v.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// int64? got;
|
|
|
|
|
+// assert(v.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == items[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// assert(v.to_array().length == 4);
|
|
|
|
|
+// assert(v.to_vector().count() == 4);
|
|
|
|
|
+// assert(v.first_or_default() == items[0]);
|
|
|
|
|
+// assert(v.last_or_default() == items[3]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/int64/buffer): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/int64/buffer", () => {
|
|
|
|
|
+// int64?[] items = {5000000000L, -5000000000L, 9223372036854775807L, 0L};
|
|
|
|
|
+//
|
|
|
|
|
+// var b = new Buffer<int64?>(4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) b.set((uint)i, items[i]);
|
|
|
|
|
+// assert(b.count() == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// int64? got;
|
|
|
|
|
+// assert(b.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == items[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/int64/ring_buffer): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/int64/ring_buffer", () => {
|
|
|
|
|
+// int64?[] items = {5000000000L, -5000000000L, 9223372036854775807L, 0L};
|
|
|
|
|
+//
|
|
|
|
|
+// var r = new RingBuffer<int64?>(4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) r.set((uint)i, items[i]);
|
|
|
|
|
+// assert(r.count() == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// int64? got;
|
|
|
|
|
+// assert(r.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == items[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/int64/series", () => {
|
|
|
|
|
+ int64?[] items = {5000000000L, -5000000000L, 9223372036854775807L, 0L};
|
|
|
|
|
+
|
|
|
|
|
+ var s = new Series<int64?>();
|
|
|
|
|
+ foreach (int64? i in items) s.add(i);
|
|
|
|
|
+ assert(s.count() == 4);
|
|
|
|
|
+ var arr = s.to_array();
|
|
|
|
|
+ assert(arr.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(arr[i] == items[i]);
|
|
|
|
|
+ assert(s.pop_start() == items[0]);
|
|
|
|
|
+ assert(s.count() == 3);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/int64/dictionary): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/int64/dictionary", () => {
|
|
|
|
|
+// int64?[] items = {5000000000L, -5000000000L, 9223372036854775807L, 0L};
|
|
|
|
|
+//
|
|
|
|
|
+// var d = new Dictionary<int64?, string>();
|
|
|
|
|
+// d.set(items[0], "zero");
|
|
|
|
|
+// d.set(items[1], "one");
|
|
|
|
|
+// assert(d.length == 2);
|
|
|
|
|
+// string got;
|
|
|
|
|
+// assert(d.try_get(items[0], out got) && got == "zero");
|
|
|
|
|
+// assert(d.try_get(items[1], out got) && got == "one");
|
|
|
|
|
+// assert(d.has(items[0]));
|
|
|
|
|
+// assert(!d.has(items[2]));
|
|
|
|
|
+// d.set(items[0], "again");
|
|
|
|
|
+// assert(d.length == 2);
|
|
|
|
|
+// assert(d.try_get(items[0], out got) && got == "again");
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/int64/hash_set): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/int64/hash_set", () => {
|
|
|
|
|
+// int64?[] items = {5000000000L, -5000000000L, 9223372036854775807L, 0L};
|
|
|
|
|
+//
|
|
|
|
|
+// var hs = new HashSet<int64?>();
|
|
|
|
|
+// assert(hs.add(items[0]));
|
|
|
|
|
+// assert(hs.add(items[1]));
|
|
|
|
|
+// assert(!hs.add(items[0]));
|
|
|
|
|
+// assert(hs.length == 2);
|
|
|
|
|
+// assert(hs.has(items[0]));
|
|
|
|
|
+// assert(hs.has(items[1]));
|
|
|
|
|
+// assert(!hs.has(items[2]));
|
|
|
|
|
+// int64? found;
|
|
|
|
|
+// assert(hs.try_find(items[1], out found) && found == items[1]);
|
|
|
|
|
+// hs.remove(items[0]);
|
|
|
|
|
+// assert(!hs.has(items[0]));
|
|
|
|
|
+// assert(hs.length == 1);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/int64/fifo", () => {
|
|
|
|
|
+ int64?[] items = {5000000000L, -5000000000L, 9223372036854775807L, 0L};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Fifo<int64?>();
|
|
|
|
|
+ foreach (int64? i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[0]);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/int64/lifo", () => {
|
|
|
|
|
+ int64?[] items = {5000000000L, -5000000000L, 9223372036854775807L, 0L};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Lifo<int64?>();
|
|
|
|
|
+ foreach (int64? i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[3]);
|
|
|
|
|
+ for (int i = 3; i >= 0; i--) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/int64/enumerable): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/int64/enumerable", () => {
|
|
|
|
|
+// int64?[] items = {5000000000L, -5000000000L, 9223372036854775807L, 0L};
|
|
|
|
|
+//
|
|
|
|
|
+// var e = Wrap.array(items);
|
|
|
|
|
+// assert(e.count() == 4);
|
|
|
|
|
+// assert(e.select<int64?>(i => i).count() == 4);
|
|
|
|
|
+// assert(e.to_array().length == 4);
|
|
|
|
|
+// assert(e.to_vector().count() == 4);
|
|
|
|
|
+// assert(e.first() == items[0]);
|
|
|
|
|
+// assert(e.last() == items[3]);
|
|
|
|
|
+// assert(e.contains(items[2]));
|
|
|
|
|
+// var n = Wrap.array(items).aggregate<int>(0, (acc, i) => acc + 1);
|
|
|
|
|
+// assert(n == 4);
|
|
|
|
|
+// var uniq = Wrap.array(items).distinct().count();
|
|
|
|
|
+// assert(uniq == (items[0] == items[3] ? 3 : 4));
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/int64/priority_queue): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/int64/priority_queue", () => {
|
|
|
|
|
+// int64?[] items = {5000000000L, -5000000000L, 9223372036854775807L, 0L};
|
|
|
|
|
+// int64?[] sorted = {-5000000000L, 0L, 5000000000L, 9223372036854775807L};
|
|
|
|
|
+//
|
|
|
|
|
+// var q = new PriorityQueue<int64?>((a, b) => Operators.comparison<int64?>()(a, b));
|
|
|
|
|
+// foreach (int64? i in items) q.push(i);
|
|
|
|
|
+// assert(q.count() == 4);
|
|
|
|
|
+// assert(q.peek() == sorted[0]);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(q.pop() == sorted[i]);
|
|
|
|
|
+// assert(q.count() == 0);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/int64/sorted_vector): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/int64/sorted_vector", () => {
|
|
|
|
|
+// int64?[] items = {5000000000L, -5000000000L, 9223372036854775807L, 0L};
|
|
|
|
|
+// int64?[] sorted = {-5000000000L, 0L, 5000000000L, 9223372036854775807L};
|
|
|
|
|
+//
|
|
|
|
|
+// var sv = new SortedVector<int64?>();
|
|
|
|
|
+// foreach (int64? i in items) sv.add(i);
|
|
|
|
|
+// assert(sv.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// int64? got;
|
|
|
|
|
+// assert(sv.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == sorted[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// var sv2 = new SortedVector<int64?>();
|
|
|
|
|
+// sv2.add_all(Wrap.array(items));
|
|
|
|
|
+// assert(sv2.length == 4);
|
|
|
|
|
+// assert(sv2.get(0) == sorted[0]);
|
|
|
|
|
+// var srt = Wrap.array(items).sort(Operators.comparison<int64?>()).to_array();
|
|
|
|
|
+// assert(srt.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(srt[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/int64/sorted_series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/int64/sorted_series", () => {
|
|
|
|
|
+// int64?[] items = {5000000000L, -5000000000L, 9223372036854775807L, 0L};
|
|
|
|
|
+// int64?[] sorted = {-5000000000L, 0L, 5000000000L, 9223372036854775807L};
|
|
|
|
|
+//
|
|
|
|
|
+// var ss = new SortedSeries<int64?>();
|
|
|
|
|
+// foreach (int64? i in items) ss.add(i);
|
|
|
|
|
+// assert(ss.length == 4);
|
|
|
|
|
+// var arr = ss.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/int64/operators", () => {
|
|
|
|
|
+ int64?[] items = {5000000000L, -5000000000L, 9223372036854775807L, 0L};
|
|
|
|
|
+
|
|
|
|
|
+ var eq = Operators.equality<int64?>();
|
|
|
|
|
+ assert(eq(items[0], items[0]));
|
|
|
|
|
+ assert(!eq(items[0], items[1]));
|
|
|
|
|
+ var st = Operators.stringify<int64?>();
|
|
|
|
|
+ assert(st(items[0]) != null && st(items[0]).length > 0);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void value_type_matrix_uint64_tests() {
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uint64/vector): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uint64/vector", () => {
|
|
|
|
|
+// uint64?[] items = {5000000000UL, 1UL, 0UL, 18446744073709551615UL};
|
|
|
|
|
+//
|
|
|
|
|
+// var v = new Vector<uint64?>();
|
|
|
|
|
+// foreach (uint64? i in items) v.add(i);
|
|
|
|
|
+// assert(v.count() == 4);
|
|
|
|
|
+// assert(v.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// uint64? got;
|
|
|
|
|
+// assert(v.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == items[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// assert(v.to_array().length == 4);
|
|
|
|
|
+// assert(v.to_vector().count() == 4);
|
|
|
|
|
+// assert(v.first_or_default() == items[0]);
|
|
|
|
|
+// assert(v.last_or_default() == items[3]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uint64/buffer): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uint64/buffer", () => {
|
|
|
|
|
+// uint64?[] items = {5000000000UL, 1UL, 0UL, 18446744073709551615UL};
|
|
|
|
|
+//
|
|
|
|
|
+// var b = new Buffer<uint64?>(4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) b.set((uint)i, items[i]);
|
|
|
|
|
+// assert(b.count() == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// uint64? got;
|
|
|
|
|
+// assert(b.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == items[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uint64/ring_buffer): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uint64/ring_buffer", () => {
|
|
|
|
|
+// uint64?[] items = {5000000000UL, 1UL, 0UL, 18446744073709551615UL};
|
|
|
|
|
+//
|
|
|
|
|
+// var r = new RingBuffer<uint64?>(4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) r.set((uint)i, items[i]);
|
|
|
|
|
+// assert(r.count() == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// uint64? got;
|
|
|
|
|
+// assert(r.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == items[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uint64/series", () => {
|
|
|
|
|
+ uint64?[] items = {5000000000UL, 1UL, 0UL, 18446744073709551615UL};
|
|
|
|
|
+
|
|
|
|
|
+ var s = new Series<uint64?>();
|
|
|
|
|
+ foreach (uint64? i in items) s.add(i);
|
|
|
|
|
+ assert(s.count() == 4);
|
|
|
|
|
+ var arr = s.to_array();
|
|
|
|
|
+ assert(arr.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(arr[i] == items[i]);
|
|
|
|
|
+ assert(s.pop_start() == items[0]);
|
|
|
|
|
+ assert(s.count() == 3);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uint64/dictionary): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uint64/dictionary", () => {
|
|
|
|
|
+// uint64?[] items = {5000000000UL, 1UL, 0UL, 18446744073709551615UL};
|
|
|
|
|
+//
|
|
|
|
|
+// var d = new Dictionary<uint64?, string>();
|
|
|
|
|
+// d.set(items[0], "zero");
|
|
|
|
|
+// d.set(items[1], "one");
|
|
|
|
|
+// assert(d.length == 2);
|
|
|
|
|
+// string got;
|
|
|
|
|
+// assert(d.try_get(items[0], out got) && got == "zero");
|
|
|
|
|
+// assert(d.try_get(items[1], out got) && got == "one");
|
|
|
|
|
+// assert(d.has(items[0]));
|
|
|
|
|
+// assert(!d.has(items[2]));
|
|
|
|
|
+// d.set(items[0], "again");
|
|
|
|
|
+// assert(d.length == 2);
|
|
|
|
|
+// assert(d.try_get(items[0], out got) && got == "again");
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uint64/hash_set): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uint64/hash_set", () => {
|
|
|
|
|
+// uint64?[] items = {5000000000UL, 1UL, 0UL, 18446744073709551615UL};
|
|
|
|
|
+//
|
|
|
|
|
+// var hs = new HashSet<uint64?>();
|
|
|
|
|
+// assert(hs.add(items[0]));
|
|
|
|
|
+// assert(hs.add(items[1]));
|
|
|
|
|
+// assert(!hs.add(items[0]));
|
|
|
|
|
+// assert(hs.length == 2);
|
|
|
|
|
+// assert(hs.has(items[0]));
|
|
|
|
|
+// assert(hs.has(items[1]));
|
|
|
|
|
+// assert(!hs.has(items[2]));
|
|
|
|
|
+// uint64? found;
|
|
|
|
|
+// assert(hs.try_find(items[1], out found) && found == items[1]);
|
|
|
|
|
+// hs.remove(items[0]);
|
|
|
|
|
+// assert(!hs.has(items[0]));
|
|
|
|
|
+// assert(hs.length == 1);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uint64/fifo", () => {
|
|
|
|
|
+ uint64?[] items = {5000000000UL, 1UL, 0UL, 18446744073709551615UL};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Fifo<uint64?>();
|
|
|
|
|
+ foreach (uint64? i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[0]);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uint64/lifo", () => {
|
|
|
|
|
+ uint64?[] items = {5000000000UL, 1UL, 0UL, 18446744073709551615UL};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Lifo<uint64?>();
|
|
|
|
|
+ foreach (uint64? i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[3]);
|
|
|
|
|
+ for (int i = 3; i >= 0; i--) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uint64/enumerable): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uint64/enumerable", () => {
|
|
|
|
|
+// uint64?[] items = {5000000000UL, 1UL, 0UL, 18446744073709551615UL};
|
|
|
|
|
+//
|
|
|
|
|
+// var e = Wrap.array(items);
|
|
|
|
|
+// assert(e.count() == 4);
|
|
|
|
|
+// assert(e.select<uint64?>(i => i).count() == 4);
|
|
|
|
|
+// assert(e.to_array().length == 4);
|
|
|
|
|
+// assert(e.to_vector().count() == 4);
|
|
|
|
|
+// assert(e.first() == items[0]);
|
|
|
|
|
+// assert(e.last() == items[3]);
|
|
|
|
|
+// assert(e.contains(items[2]));
|
|
|
|
|
+// var n = Wrap.array(items).aggregate<int>(0, (acc, i) => acc + 1);
|
|
|
|
|
+// assert(n == 4);
|
|
|
|
|
+// var uniq = Wrap.array(items).distinct().count();
|
|
|
|
|
+// assert(uniq == (items[0] == items[3] ? 3 : 4));
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uint64/priority_queue): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uint64/priority_queue", () => {
|
|
|
|
|
+// uint64?[] items = {5000000000UL, 1UL, 0UL, 18446744073709551615UL};
|
|
|
|
|
+// uint64?[] sorted = {0UL, 1UL, 5000000000UL, 18446744073709551615UL};
|
|
|
|
|
+//
|
|
|
|
|
+// var q = new PriorityQueue<uint64?>((a, b) => Operators.comparison<uint64?>()(a, b));
|
|
|
|
|
+// foreach (uint64? i in items) q.push(i);
|
|
|
|
|
+// assert(q.count() == 4);
|
|
|
|
|
+// assert(q.peek() == sorted[0]);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(q.pop() == sorted[i]);
|
|
|
|
|
+// assert(q.count() == 0);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uint64/sorted_vector): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uint64/sorted_vector", () => {
|
|
|
|
|
+// uint64?[] items = {5000000000UL, 1UL, 0UL, 18446744073709551615UL};
|
|
|
|
|
+// uint64?[] sorted = {0UL, 1UL, 5000000000UL, 18446744073709551615UL};
|
|
|
|
|
+//
|
|
|
|
|
+// var sv = new SortedVector<uint64?>();
|
|
|
|
|
+// foreach (uint64? i in items) sv.add(i);
|
|
|
|
|
+// assert(sv.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// uint64? got;
|
|
|
|
|
+// assert(sv.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == sorted[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// var sv2 = new SortedVector<uint64?>();
|
|
|
|
|
+// sv2.add_all(Wrap.array(items));
|
|
|
|
|
+// assert(sv2.length == 4);
|
|
|
|
|
+// assert(sv2.get(0) == sorted[0]);
|
|
|
|
|
+// var srt = Wrap.array(items).sort(Operators.comparison<uint64?>()).to_array();
|
|
|
|
|
+// assert(srt.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(srt[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uint64/sorted_series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uint64/sorted_series", () => {
|
|
|
|
|
+// uint64?[] items = {5000000000UL, 1UL, 0UL, 18446744073709551615UL};
|
|
|
|
|
+// uint64?[] sorted = {0UL, 1UL, 5000000000UL, 18446744073709551615UL};
|
|
|
|
|
+//
|
|
|
|
|
+// var ss = new SortedSeries<uint64?>();
|
|
|
|
|
+// foreach (uint64? i in items) ss.add(i);
|
|
|
|
|
+// assert(ss.length == 4);
|
|
|
|
|
+// var arr = ss.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uint64/operators", () => {
|
|
|
|
|
+ uint64?[] items = {5000000000UL, 1UL, 0UL, 18446744073709551615UL};
|
|
|
|
|
+
|
|
|
|
|
+ var eq = Operators.equality<uint64?>();
|
|
|
|
|
+ assert(eq(items[0], items[0]));
|
|
|
|
|
+ assert(!eq(items[0], items[1]));
|
|
|
|
|
+ var st = Operators.stringify<uint64?>();
|
|
|
|
|
+ assert(st(items[0]) != null && st(items[0]).length > 0);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void value_type_matrix_float_tests() {
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/float/vector): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/float/vector", () => {
|
|
|
|
|
+// float?[] items = {1.5f, -2.25f, 100.5f, 0.0f};
|
|
|
|
|
+//
|
|
|
|
|
+// var v = new Vector<float?>();
|
|
|
|
|
+// foreach (float? i in items) v.add(i);
|
|
|
|
|
+// assert(v.count() == 4);
|
|
|
|
|
+// assert(v.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// float? got;
|
|
|
|
|
+// assert(v.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == items[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// assert(v.to_array().length == 4);
|
|
|
|
|
+// assert(v.to_vector().count() == 4);
|
|
|
|
|
+// assert(v.first_or_default() == items[0]);
|
|
|
|
|
+// assert(v.last_or_default() == items[3]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/float/buffer): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/float/buffer", () => {
|
|
|
|
|
+// float?[] items = {1.5f, -2.25f, 100.5f, 0.0f};
|
|
|
|
|
+//
|
|
|
|
|
+// var b = new Buffer<float?>(4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) b.set((uint)i, items[i]);
|
|
|
|
|
+// assert(b.count() == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// float? got;
|
|
|
|
|
+// assert(b.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == items[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/float/ring_buffer): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/float/ring_buffer", () => {
|
|
|
|
|
+// float?[] items = {1.5f, -2.25f, 100.5f, 0.0f};
|
|
|
|
|
+//
|
|
|
|
|
+// var r = new RingBuffer<float?>(4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) r.set((uint)i, items[i]);
|
|
|
|
|
+// assert(r.count() == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// float? got;
|
|
|
|
|
+// assert(r.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == items[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/float/series", () => {
|
|
|
|
|
+ float?[] items = {1.5f, -2.25f, 100.5f, 0.0f};
|
|
|
|
|
+
|
|
|
|
|
+ var s = new Series<float?>();
|
|
|
|
|
+ foreach (float? i in items) s.add(i);
|
|
|
|
|
+ assert(s.count() == 4);
|
|
|
|
|
+ var arr = s.to_array();
|
|
|
|
|
+ assert(arr.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(arr[i] == items[i]);
|
|
|
|
|
+ assert(s.pop_start() == items[0]);
|
|
|
|
|
+ assert(s.count() == 3);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/float/dictionary): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/float/dictionary", () => {
|
|
|
|
|
+// float?[] items = {1.5f, -2.25f, 100.5f, 0.0f};
|
|
|
|
|
+//
|
|
|
|
|
+// var d = new Dictionary<float?, string>();
|
|
|
|
|
+// d.set(items[0], "zero");
|
|
|
|
|
+// d.set(items[1], "one");
|
|
|
|
|
+// assert(d.length == 2);
|
|
|
|
|
+// string got;
|
|
|
|
|
+// assert(d.try_get(items[0], out got) && got == "zero");
|
|
|
|
|
+// assert(d.try_get(items[1], out got) && got == "one");
|
|
|
|
|
+// assert(d.has(items[0]));
|
|
|
|
|
+// assert(!d.has(items[2]));
|
|
|
|
|
+// d.set(items[0], "again");
|
|
|
|
|
+// assert(d.length == 2);
|
|
|
|
|
+// assert(d.try_get(items[0], out got) && got == "again");
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/float/hash_set): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/float/hash_set", () => {
|
|
|
|
|
+// float?[] items = {1.5f, -2.25f, 100.5f, 0.0f};
|
|
|
|
|
+//
|
|
|
|
|
+// var hs = new HashSet<float?>();
|
|
|
|
|
+// assert(hs.add(items[0]));
|
|
|
|
|
+// assert(hs.add(items[1]));
|
|
|
|
|
+// assert(!hs.add(items[0]));
|
|
|
|
|
+// assert(hs.length == 2);
|
|
|
|
|
+// assert(hs.has(items[0]));
|
|
|
|
|
+// assert(hs.has(items[1]));
|
|
|
|
|
+// assert(!hs.has(items[2]));
|
|
|
|
|
+// float? found;
|
|
|
|
|
+// assert(hs.try_find(items[1], out found) && found == items[1]);
|
|
|
|
|
+// hs.remove(items[0]);
|
|
|
|
|
+// assert(!hs.has(items[0]));
|
|
|
|
|
+// assert(hs.length == 1);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/float/fifo", () => {
|
|
|
|
|
+ float?[] items = {1.5f, -2.25f, 100.5f, 0.0f};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Fifo<float?>();
|
|
|
|
|
+ foreach (float? i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[0]);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/float/lifo", () => {
|
|
|
|
|
+ float?[] items = {1.5f, -2.25f, 100.5f, 0.0f};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Lifo<float?>();
|
|
|
|
|
+ foreach (float? i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[3]);
|
|
|
|
|
+ for (int i = 3; i >= 0; i--) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/float/enumerable): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/float/enumerable", () => {
|
|
|
|
|
+// float?[] items = {1.5f, -2.25f, 100.5f, 0.0f};
|
|
|
|
|
+//
|
|
|
|
|
+// var e = Wrap.array(items);
|
|
|
|
|
+// assert(e.count() == 4);
|
|
|
|
|
+// assert(e.select<float?>(i => i).count() == 4);
|
|
|
|
|
+// assert(e.to_array().length == 4);
|
|
|
|
|
+// assert(e.to_vector().count() == 4);
|
|
|
|
|
+// assert(e.first() == items[0]);
|
|
|
|
|
+// assert(e.last() == items[3]);
|
|
|
|
|
+// assert(e.contains(items[2]));
|
|
|
|
|
+// var n = Wrap.array(items).aggregate<int>(0, (acc, i) => acc + 1);
|
|
|
|
|
+// assert(n == 4);
|
|
|
|
|
+// var uniq = Wrap.array(items).distinct().count();
|
|
|
|
|
+// assert(uniq == (items[0] == items[3] ? 3 : 4));
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/float/priority_queue): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/float/priority_queue", () => {
|
|
|
|
|
+// float?[] items = {1.5f, -2.25f, 100.5f, 0.0f};
|
|
|
|
|
+// float?[] sorted = {-2.25f, 0.0f, 1.5f, 100.5f};
|
|
|
|
|
+//
|
|
|
|
|
+// var q = new PriorityQueue<float?>((a, b) => Operators.comparison<float?>()(a, b));
|
|
|
|
|
+// foreach (float? i in items) q.push(i);
|
|
|
|
|
+// assert(q.count() == 4);
|
|
|
|
|
+// assert(q.peek() == sorted[0]);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(q.pop() == sorted[i]);
|
|
|
|
|
+// assert(q.count() == 0);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/float/sorted_vector): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/float/sorted_vector", () => {
|
|
|
|
|
+// float?[] items = {1.5f, -2.25f, 100.5f, 0.0f};
|
|
|
|
|
+// float?[] sorted = {-2.25f, 0.0f, 1.5f, 100.5f};
|
|
|
|
|
+//
|
|
|
|
|
+// var sv = new SortedVector<float?>();
|
|
|
|
|
+// foreach (float? i in items) sv.add(i);
|
|
|
|
|
+// assert(sv.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// float? got;
|
|
|
|
|
+// assert(sv.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == sorted[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// var sv2 = new SortedVector<float?>();
|
|
|
|
|
+// sv2.add_all(Wrap.array(items));
|
|
|
|
|
+// assert(sv2.length == 4);
|
|
|
|
|
+// assert(sv2.get(0) == sorted[0]);
|
|
|
|
|
+// var srt = Wrap.array(items).sort(Operators.comparison<float?>()).to_array();
|
|
|
|
|
+// assert(srt.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(srt[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/float/sorted_series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/float/sorted_series", () => {
|
|
|
|
|
+// float?[] items = {1.5f, -2.25f, 100.5f, 0.0f};
|
|
|
|
|
+// float?[] sorted = {-2.25f, 0.0f, 1.5f, 100.5f};
|
|
|
|
|
+//
|
|
|
|
|
+// var ss = new SortedSeries<float?>();
|
|
|
|
|
+// foreach (float? i in items) ss.add(i);
|
|
|
|
|
+// assert(ss.length == 4);
|
|
|
|
|
+// var arr = ss.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/float/operators", () => {
|
|
|
|
|
+ float?[] items = {1.5f, -2.25f, 100.5f, 0.0f};
|
|
|
|
|
+
|
|
|
|
|
+ var eq = Operators.equality<float?>();
|
|
|
|
|
+ assert(eq(items[0], items[0]));
|
|
|
|
|
+ assert(!eq(items[0], items[1]));
|
|
|
|
|
+ var st = Operators.stringify<float?>();
|
|
|
|
|
+ assert(st(items[0]) != null && st(items[0]).length > 0);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void value_type_matrix_double_tests() {
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/double/vector", () => {
|
|
|
|
|
+ double?[] items = {1.5, -2.25, 100.5, 0.0};
|
|
|
|
|
+
|
|
|
|
|
+ var v = new Vector<double?>();
|
|
|
|
|
+ foreach (double? i in items) v.add(i);
|
|
|
|
|
+ assert(v.count() == 4);
|
|
|
|
|
+ assert(v.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ double? got;
|
|
|
|
|
+ assert(v.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ assert(v.to_array().length == 4);
|
|
|
|
|
+ assert(v.to_vector().count() == 4);
|
|
|
|
|
+ assert(v.first_or_default() == items[0]);
|
|
|
|
|
+ assert(v.last_or_default() == items[3]);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/double/buffer", () => {
|
|
|
|
|
+ double?[] items = {1.5, -2.25, 100.5, 0.0};
|
|
|
|
|
+
|
|
|
|
|
+ var b = new Buffer<double?>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) b.set((uint)i, items[i]);
|
|
|
|
|
+ assert(b.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ double? got;
|
|
|
|
|
+ assert(b.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/double/ring_buffer", () => {
|
|
|
|
|
+ double?[] items = {1.5, -2.25, 100.5, 0.0};
|
|
|
|
|
+
|
|
|
|
|
+ var r = new RingBuffer<double?>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) r.set((uint)i, items[i]);
|
|
|
|
|
+ assert(r.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ double? got;
|
|
|
|
|
+ assert(r.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/double/series", () => {
|
|
|
|
|
+ double?[] items = {1.5, -2.25, 100.5, 0.0};
|
|
|
|
|
+
|
|
|
|
|
+ var s = new Series<double?>();
|
|
|
|
|
+ foreach (double? i in items) s.add(i);
|
|
|
|
|
+ assert(s.count() == 4);
|
|
|
|
|
+ var arr = s.to_array();
|
|
|
|
|
+ assert(arr.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(arr[i] == items[i]);
|
|
|
|
|
+ assert(s.pop_start() == items[0]);
|
|
|
|
|
+ assert(s.count() == 3);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/double/dictionary", () => {
|
|
|
|
|
+ double?[] items = {1.5, -2.25, 100.5, 0.0};
|
|
|
|
|
+
|
|
|
|
|
+ var d = new Dictionary<double?, string>();
|
|
|
|
|
+ d.set(items[0], "zero");
|
|
|
|
|
+ d.set(items[1], "one");
|
|
|
|
|
+ assert(d.length == 2);
|
|
|
|
|
+ string got;
|
|
|
|
|
+ assert(d.try_get(items[0], out got) && got == "zero");
|
|
|
|
|
+ assert(d.try_get(items[1], out got) && got == "one");
|
|
|
|
|
+ assert(d.has(items[0]));
|
|
|
|
|
+ assert(!d.has(items[2]));
|
|
|
|
|
+ d.set(items[0], "again");
|
|
|
|
|
+ assert(d.length == 2);
|
|
|
|
|
+ assert(d.try_get(items[0], out got) && got == "again");
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/double/hash_set", () => {
|
|
|
|
|
+ double?[] items = {1.5, -2.25, 100.5, 0.0};
|
|
|
|
|
+
|
|
|
|
|
+ var hs = new HashSet<double?>();
|
|
|
|
|
+ assert(hs.add(items[0]));
|
|
|
|
|
+ assert(hs.add(items[1]));
|
|
|
|
|
+ assert(!hs.add(items[0]));
|
|
|
|
|
+ assert(hs.length == 2);
|
|
|
|
|
+ assert(hs.has(items[0]));
|
|
|
|
|
+ assert(hs.has(items[1]));
|
|
|
|
|
+ assert(!hs.has(items[2]));
|
|
|
|
|
+ double? found;
|
|
|
|
|
+ assert(hs.try_find(items[1], out found) && found == items[1]);
|
|
|
|
|
+ hs.remove(items[0]);
|
|
|
|
|
+ assert(!hs.has(items[0]));
|
|
|
|
|
+ assert(hs.length == 1);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/double/fifo", () => {
|
|
|
|
|
+ double?[] items = {1.5, -2.25, 100.5, 0.0};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Fifo<double?>();
|
|
|
|
|
+ foreach (double? i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[0]);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/double/lifo", () => {
|
|
|
|
|
+ double?[] items = {1.5, -2.25, 100.5, 0.0};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Lifo<double?>();
|
|
|
|
|
+ foreach (double? i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[3]);
|
|
|
|
|
+ for (int i = 3; i >= 0; i--) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/double/enumerable", () => {
|
|
|
|
|
+ double?[] items = {1.5, -2.25, 100.5, 0.0};
|
|
|
|
|
+
|
|
|
|
|
+ var e = Wrap.array(items);
|
|
|
|
|
+ assert(e.count() == 4);
|
|
|
|
|
+ assert(e.select<double?>(i => i).count() == 4);
|
|
|
|
|
+ assert(e.to_array().length == 4);
|
|
|
|
|
+ assert(e.to_vector().count() == 4);
|
|
|
|
|
+ assert(e.first() == items[0]);
|
|
|
|
|
+ assert(e.last() == items[3]);
|
|
|
|
|
+ assert(e.contains(items[2]));
|
|
|
|
|
+ var n = Wrap.array(items).aggregate<int>(0, (acc, i) => acc + 1);
|
|
|
|
|
+ assert(n == 4);
|
|
|
|
|
+ var uniq = Wrap.array(items).distinct().count();
|
|
|
|
|
+ assert(uniq == (items[0] == items[3] ? 3 : 4));
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/double/priority_queue", () => {
|
|
|
|
|
+ double?[] items = {1.5, -2.25, 100.5, 0.0};
|
|
|
|
|
+ double?[] sorted = {-2.25, 0.0, 1.5, 100.5};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new PriorityQueue<double?>((a, b) => Operators.comparison<double?>()(a, b));
|
|
|
|
|
+ foreach (double? i in items) q.push(i);
|
|
|
|
|
+ assert(q.count() == 4);
|
|
|
|
|
+ assert(q.peek() == sorted[0]);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(q.pop() == sorted[i]);
|
|
|
|
|
+ assert(q.count() == 0);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/double/sorted_vector", () => {
|
|
|
|
|
+ double?[] items = {1.5, -2.25, 100.5, 0.0};
|
|
|
|
|
+ double?[] sorted = {-2.25, 0.0, 1.5, 100.5};
|
|
|
|
|
+
|
|
|
|
|
+ var sv = new SortedVector<double?>();
|
|
|
|
|
+ foreach (double? i in items) sv.add(i);
|
|
|
|
|
+ assert(sv.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ double? got;
|
|
|
|
|
+ assert(sv.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == sorted[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ var sv2 = new SortedVector<double?>();
|
|
|
|
|
+ sv2.add_all(Wrap.array(items));
|
|
|
|
|
+ assert(sv2.length == 4);
|
|
|
|
|
+ assert(sv2.get(0) == sorted[0]);
|
|
|
|
|
+ var srt = Wrap.array(items).sort(Operators.comparison<double?>()).to_array();
|
|
|
|
|
+ assert(srt.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(srt[i] == sorted[i]);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/double/sorted_series", () => {
|
|
|
|
|
+ double?[] items = {1.5, -2.25, 100.5, 0.0};
|
|
|
|
|
+ double?[] sorted = {-2.25, 0.0, 1.5, 100.5};
|
|
|
|
|
+
|
|
|
|
|
+ var ss = new SortedSeries<double?>();
|
|
|
|
|
+ foreach (double? i in items) ss.add(i);
|
|
|
|
|
+ assert(ss.length == 4);
|
|
|
|
|
+ var arr = ss.to_array();
|
|
|
|
|
+ assert(arr.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(arr[i] == sorted[i]);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/double/operators", () => {
|
|
|
|
|
+ double?[] items = {1.5, -2.25, 100.5, 0.0};
|
|
|
|
|
+
|
|
|
|
|
+ var eq = Operators.equality<double?>();
|
|
|
|
|
+ assert(eq(items[0], items[0]));
|
|
|
|
|
+ assert(!eq(items[0], items[1]));
|
|
|
|
|
+ var st = Operators.stringify<double?>();
|
|
|
|
|
+ assert(st(items[0]) != null && st(items[0]).length > 0);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void value_type_matrix_char_tests() {
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/char/vector", () => {
|
|
|
|
|
+ char[] items = {'a', 'Z', '0', '~'};
|
|
|
|
|
+
|
|
|
|
|
+ var v = new Vector<char>();
|
|
|
|
|
+ foreach (char i in items) v.add(i);
|
|
|
|
|
+ assert(v.count() == 4);
|
|
|
|
|
+ assert(v.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ char got;
|
|
|
|
|
+ assert(v.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ assert(v.to_array().length == 4);
|
|
|
|
|
+ assert(v.to_vector().count() == 4);
|
|
|
|
|
+ assert(v.first_or_default() == items[0]);
|
|
|
|
|
+ assert(v.last_or_default() == items[3]);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/char/buffer", () => {
|
|
|
|
|
+ char[] items = {'a', 'Z', '0', '~'};
|
|
|
|
|
+
|
|
|
|
|
+ var b = new Buffer<char>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) b.set((uint)i, items[i]);
|
|
|
|
|
+ assert(b.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ char got;
|
|
|
|
|
+ assert(b.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/char/ring_buffer", () => {
|
|
|
|
|
+ char[] items = {'a', 'Z', '0', '~'};
|
|
|
|
|
+
|
|
|
|
|
+ var r = new RingBuffer<char>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) r.set((uint)i, items[i]);
|
|
|
|
|
+ assert(r.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ char got;
|
|
|
|
|
+ assert(r.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/char/series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/char/series", () => {
|
|
|
|
|
+// char[] items = {'a', 'Z', '0', '~'};
|
|
|
|
|
+//
|
|
|
|
|
+// var s = new Series<char>();
|
|
|
|
|
+// foreach (char i in items) s.add(i);
|
|
|
|
|
+// assert(s.count() == 4);
|
|
|
|
|
+// var arr = s.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == items[i]);
|
|
|
|
|
+// assert(s.pop_start() == items[0]);
|
|
|
|
|
+// assert(s.count() == 3);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/char/dictionary", () => {
|
|
|
|
|
+ char[] items = {'a', 'Z', '0', '~'};
|
|
|
|
|
+
|
|
|
|
|
+ var d = new Dictionary<char, string>();
|
|
|
|
|
+ d.set(items[0], "zero");
|
|
|
|
|
+ d.set(items[1], "one");
|
|
|
|
|
+ assert(d.length == 2);
|
|
|
|
|
+ string got;
|
|
|
|
|
+ assert(d.try_get(items[0], out got) && got == "zero");
|
|
|
|
|
+ assert(d.try_get(items[1], out got) && got == "one");
|
|
|
|
|
+ assert(d.has(items[0]));
|
|
|
|
|
+ assert(!d.has(items[2]));
|
|
|
|
|
+ d.set(items[0], "again");
|
|
|
|
|
+ assert(d.length == 2);
|
|
|
|
|
+ assert(d.try_get(items[0], out got) && got == "again");
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/char/hash_set", () => {
|
|
|
|
|
+ char[] items = {'a', 'Z', '0', '~'};
|
|
|
|
|
+
|
|
|
|
|
+ var hs = new HashSet<char>();
|
|
|
|
|
+ assert(hs.add(items[0]));
|
|
|
|
|
+ assert(hs.add(items[1]));
|
|
|
|
|
+ assert(!hs.add(items[0]));
|
|
|
|
|
+ assert(hs.length == 2);
|
|
|
|
|
+ assert(hs.has(items[0]));
|
|
|
|
|
+ assert(hs.has(items[1]));
|
|
|
|
|
+ assert(!hs.has(items[2]));
|
|
|
|
|
+ char found;
|
|
|
|
|
+ assert(hs.try_find(items[1], out found) && found == items[1]);
|
|
|
|
|
+ hs.remove(items[0]);
|
|
|
|
|
+ assert(!hs.has(items[0]));
|
|
|
|
|
+ assert(hs.length == 1);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/char/fifo", () => {
|
|
|
|
|
+ char[] items = {'a', 'Z', '0', '~'};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Fifo<char>();
|
|
|
|
|
+ foreach (char i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[0]);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/char/lifo", () => {
|
|
|
|
|
+ char[] items = {'a', 'Z', '0', '~'};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Lifo<char>();
|
|
|
|
|
+ foreach (char i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[3]);
|
|
|
|
|
+ for (int i = 3; i >= 0; i--) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/char/enumerable", () => {
|
|
|
|
|
+ char[] items = {'a', 'Z', '0', '~'};
|
|
|
|
|
+
|
|
|
|
|
+ var e = Wrap.array(items);
|
|
|
|
|
+ assert(e.count() == 4);
|
|
|
|
|
+ assert(e.select<char>(i => i).count() == 4);
|
|
|
|
|
+ assert(e.to_array().length == 4);
|
|
|
|
|
+ assert(e.to_vector().count() == 4);
|
|
|
|
|
+ assert(e.first() == items[0]);
|
|
|
|
|
+ assert(e.last() == items[3]);
|
|
|
|
|
+ assert(e.contains(items[2]));
|
|
|
|
|
+ var n = Wrap.array(items).aggregate<int>(0, (acc, i) => acc + 1);
|
|
|
|
|
+ assert(n == 4);
|
|
|
|
|
+ var uniq = Wrap.array(items).distinct().count();
|
|
|
|
|
+ assert(uniq == (items[0] == items[3] ? 3 : 4));
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/char/priority_queue): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/char/priority_queue", () => {
|
|
|
|
|
+// char[] items = {'a', 'Z', '0', '~'};
|
|
|
|
|
+// char[] sorted = {'0', 'Z', 'a', '~'};
|
|
|
|
|
+//
|
|
|
|
|
+// var q = new PriorityQueue<char>((a, b) => Operators.comparison<char>()(a, b));
|
|
|
|
|
+// foreach (char i in items) q.push(i);
|
|
|
|
|
+// assert(q.count() == 4);
|
|
|
|
|
+// assert(q.peek() == sorted[0]);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(q.pop() == sorted[i]);
|
|
|
|
|
+// assert(q.count() == 0);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/char/sorted_vector): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/char/sorted_vector", () => {
|
|
|
|
|
+// char[] items = {'a', 'Z', '0', '~'};
|
|
|
|
|
+// char[] sorted = {'0', 'Z', 'a', '~'};
|
|
|
|
|
+//
|
|
|
|
|
+// var sv = new SortedVector<char>();
|
|
|
|
|
+// foreach (char i in items) sv.add(i);
|
|
|
|
|
+// assert(sv.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// char got;
|
|
|
|
|
+// assert(sv.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == sorted[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// var sv2 = new SortedVector<char>();
|
|
|
|
|
+// sv2.add_all(Wrap.array(items));
|
|
|
|
|
+// assert(sv2.length == 4);
|
|
|
|
|
+// assert(sv2.get(0) == sorted[0]);
|
|
|
|
|
+// var srt = Wrap.array(items).sort(Operators.comparison<char>()).to_array();
|
|
|
|
|
+// assert(srt.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(srt[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/char/sorted_series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/char/sorted_series", () => {
|
|
|
|
|
+// char[] items = {'a', 'Z', '0', '~'};
|
|
|
|
|
+// char[] sorted = {'0', 'Z', 'a', '~'};
|
|
|
|
|
+//
|
|
|
|
|
+// var ss = new SortedSeries<char>();
|
|
|
|
|
+// foreach (char i in items) ss.add(i);
|
|
|
|
|
+// assert(ss.length == 4);
|
|
|
|
|
+// var arr = ss.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/char/operators", () => {
|
|
|
|
|
+ char[] items = {'a', 'Z', '0', '~'};
|
|
|
|
|
+
|
|
|
|
|
+ var eq = Operators.equality<char>();
|
|
|
|
|
+ assert(eq(items[0], items[0]));
|
|
|
|
|
+ assert(!eq(items[0], items[1]));
|
|
|
|
|
+ var st = Operators.stringify<char>();
|
|
|
|
|
+ assert(st(items[0]) != null && st(items[0]).length > 0);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void value_type_matrix_uchar_tests() {
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uchar/vector", () => {
|
|
|
|
|
+ uchar[] items = {(uchar)65, (uchar)200, (uchar)0, (uchar)255};
|
|
|
|
|
+
|
|
|
|
|
+ var v = new Vector<uchar>();
|
|
|
|
|
+ foreach (uchar i in items) v.add(i);
|
|
|
|
|
+ assert(v.count() == 4);
|
|
|
|
|
+ assert(v.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ uchar got;
|
|
|
|
|
+ assert(v.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ assert(v.to_array().length == 4);
|
|
|
|
|
+ assert(v.to_vector().count() == 4);
|
|
|
|
|
+ assert(v.first_or_default() == items[0]);
|
|
|
|
|
+ assert(v.last_or_default() == items[3]);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uchar/buffer", () => {
|
|
|
|
|
+ uchar[] items = {(uchar)65, (uchar)200, (uchar)0, (uchar)255};
|
|
|
|
|
+
|
|
|
|
|
+ var b = new Buffer<uchar>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) b.set((uint)i, items[i]);
|
|
|
|
|
+ assert(b.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ uchar got;
|
|
|
|
|
+ assert(b.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uchar/ring_buffer", () => {
|
|
|
|
|
+ uchar[] items = {(uchar)65, (uchar)200, (uchar)0, (uchar)255};
|
|
|
|
|
+
|
|
|
|
|
+ var r = new RingBuffer<uchar>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) r.set((uint)i, items[i]);
|
|
|
|
|
+ assert(r.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ uchar got;
|
|
|
|
|
+ assert(r.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uchar/series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uchar/series", () => {
|
|
|
|
|
+// uchar[] items = {(uchar)65, (uchar)200, (uchar)0, (uchar)255};
|
|
|
|
|
+//
|
|
|
|
|
+// var s = new Series<uchar>();
|
|
|
|
|
+// foreach (uchar i in items) s.add(i);
|
|
|
|
|
+// assert(s.count() == 4);
|
|
|
|
|
+// var arr = s.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == items[i]);
|
|
|
|
|
+// assert(s.pop_start() == items[0]);
|
|
|
|
|
+// assert(s.count() == 3);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uchar/dictionary", () => {
|
|
|
|
|
+ uchar[] items = {(uchar)65, (uchar)200, (uchar)0, (uchar)255};
|
|
|
|
|
+
|
|
|
|
|
+ var d = new Dictionary<uchar, string>();
|
|
|
|
|
+ d.set(items[0], "zero");
|
|
|
|
|
+ d.set(items[1], "one");
|
|
|
|
|
+ assert(d.length == 2);
|
|
|
|
|
+ string got;
|
|
|
|
|
+ assert(d.try_get(items[0], out got) && got == "zero");
|
|
|
|
|
+ assert(d.try_get(items[1], out got) && got == "one");
|
|
|
|
|
+ assert(d.has(items[0]));
|
|
|
|
|
+ assert(!d.has(items[2]));
|
|
|
|
|
+ d.set(items[0], "again");
|
|
|
|
|
+ assert(d.length == 2);
|
|
|
|
|
+ assert(d.try_get(items[0], out got) && got == "again");
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uchar/hash_set", () => {
|
|
|
|
|
+ uchar[] items = {(uchar)65, (uchar)200, (uchar)0, (uchar)255};
|
|
|
|
|
+
|
|
|
|
|
+ var hs = new HashSet<uchar>();
|
|
|
|
|
+ assert(hs.add(items[0]));
|
|
|
|
|
+ assert(hs.add(items[1]));
|
|
|
|
|
+ assert(!hs.add(items[0]));
|
|
|
|
|
+ assert(hs.length == 2);
|
|
|
|
|
+ assert(hs.has(items[0]));
|
|
|
|
|
+ assert(hs.has(items[1]));
|
|
|
|
|
+ assert(!hs.has(items[2]));
|
|
|
|
|
+ uchar found;
|
|
|
|
|
+ assert(hs.try_find(items[1], out found) && found == items[1]);
|
|
|
|
|
+ hs.remove(items[0]);
|
|
|
|
|
+ assert(!hs.has(items[0]));
|
|
|
|
|
+ assert(hs.length == 1);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uchar/fifo", () => {
|
|
|
|
|
+ uchar[] items = {(uchar)65, (uchar)200, (uchar)0, (uchar)255};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Fifo<uchar>();
|
|
|
|
|
+ foreach (uchar i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[0]);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uchar/lifo", () => {
|
|
|
|
|
+ uchar[] items = {(uchar)65, (uchar)200, (uchar)0, (uchar)255};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Lifo<uchar>();
|
|
|
|
|
+ foreach (uchar i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[3]);
|
|
|
|
|
+ for (int i = 3; i >= 0; i--) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uchar/enumerable", () => {
|
|
|
|
|
+ uchar[] items = {(uchar)65, (uchar)200, (uchar)0, (uchar)255};
|
|
|
|
|
+
|
|
|
|
|
+ var e = Wrap.array(items);
|
|
|
|
|
+ assert(e.count() == 4);
|
|
|
|
|
+ assert(e.select<uchar>(i => i).count() == 4);
|
|
|
|
|
+ assert(e.to_array().length == 4);
|
|
|
|
|
+ assert(e.to_vector().count() == 4);
|
|
|
|
|
+ assert(e.first() == items[0]);
|
|
|
|
|
+ assert(e.last() == items[3]);
|
|
|
|
|
+ assert(e.contains(items[2]));
|
|
|
|
|
+ var n = Wrap.array(items).aggregate<int>(0, (acc, i) => acc + 1);
|
|
|
|
|
+ assert(n == 4);
|
|
|
|
|
+ var uniq = Wrap.array(items).distinct().count();
|
|
|
|
|
+ assert(uniq == (items[0] == items[3] ? 3 : 4));
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uchar/priority_queue): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uchar/priority_queue", () => {
|
|
|
|
|
+// uchar[] items = {(uchar)65, (uchar)200, (uchar)0, (uchar)255};
|
|
|
|
|
+// uchar[] sorted = {(uchar)0, (uchar)65, (uchar)200, (uchar)255};
|
|
|
|
|
+//
|
|
|
|
|
+// var q = new PriorityQueue<uchar>((a, b) => Operators.comparison<uchar>()(a, b));
|
|
|
|
|
+// foreach (uchar i in items) q.push(i);
|
|
|
|
|
+// assert(q.count() == 4);
|
|
|
|
|
+// assert(q.peek() == sorted[0]);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(q.pop() == sorted[i]);
|
|
|
|
|
+// assert(q.count() == 0);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uchar/sorted_vector): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uchar/sorted_vector", () => {
|
|
|
|
|
+// uchar[] items = {(uchar)65, (uchar)200, (uchar)0, (uchar)255};
|
|
|
|
|
+// uchar[] sorted = {(uchar)0, (uchar)65, (uchar)200, (uchar)255};
|
|
|
|
|
+//
|
|
|
|
|
+// var sv = new SortedVector<uchar>();
|
|
|
|
|
+// foreach (uchar i in items) sv.add(i);
|
|
|
|
|
+// assert(sv.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// uchar got;
|
|
|
|
|
+// assert(sv.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == sorted[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// var sv2 = new SortedVector<uchar>();
|
|
|
|
|
+// sv2.add_all(Wrap.array(items));
|
|
|
|
|
+// assert(sv2.length == 4);
|
|
|
|
|
+// assert(sv2.get(0) == sorted[0]);
|
|
|
|
|
+// var srt = Wrap.array(items).sort(Operators.comparison<uchar>()).to_array();
|
|
|
|
|
+// assert(srt.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(srt[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/uchar/sorted_series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/uchar/sorted_series", () => {
|
|
|
|
|
+// uchar[] items = {(uchar)65, (uchar)200, (uchar)0, (uchar)255};
|
|
|
|
|
+// uchar[] sorted = {(uchar)0, (uchar)65, (uchar)200, (uchar)255};
|
|
|
|
|
+//
|
|
|
|
|
+// var ss = new SortedSeries<uchar>();
|
|
|
|
|
+// foreach (uchar i in items) ss.add(i);
|
|
|
|
|
+// assert(ss.length == 4);
|
|
|
|
|
+// var arr = ss.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/uchar/operators", () => {
|
|
|
|
|
+ uchar[] items = {(uchar)65, (uchar)200, (uchar)0, (uchar)255};
|
|
|
|
|
+
|
|
|
|
|
+ var eq = Operators.equality<uchar>();
|
|
|
|
|
+ assert(eq(items[0], items[0]));
|
|
|
|
|
+ assert(!eq(items[0], items[1]));
|
|
|
|
|
+ var st = Operators.stringify<uchar>();
|
|
|
|
|
+ assert(st(items[0]) != null && st(items[0]).length > 0);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void value_type_matrix_enum_tests() {
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/enum/vector", () => {
|
|
|
|
|
+ ValueTypeFruit[] items = {ValueTypeFruit.APPLE, ValueTypeFruit.BANANA, ValueTypeFruit.CHERRY, ValueTypeFruit.APPLE};
|
|
|
|
|
+
|
|
|
|
|
+ var v = new Vector<ValueTypeFruit>();
|
|
|
|
|
+ foreach (ValueTypeFruit i in items) v.add(i);
|
|
|
|
|
+ assert(v.count() == 4);
|
|
|
|
|
+ assert(v.length == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ ValueTypeFruit got;
|
|
|
|
|
+ assert(v.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ assert(v.to_array().length == 4);
|
|
|
|
|
+ assert(v.to_vector().count() == 4);
|
|
|
|
|
+ assert(v.first_or_default() == items[0]);
|
|
|
|
|
+ assert(v.last_or_default() == items[3]);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/enum/buffer", () => {
|
|
|
|
|
+ ValueTypeFruit[] items = {ValueTypeFruit.APPLE, ValueTypeFruit.BANANA, ValueTypeFruit.CHERRY, ValueTypeFruit.APPLE};
|
|
|
|
|
+
|
|
|
|
|
+ var b = new Buffer<ValueTypeFruit>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) b.set((uint)i, items[i]);
|
|
|
|
|
+ assert(b.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ ValueTypeFruit got;
|
|
|
|
|
+ assert(b.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/enum/ring_buffer", () => {
|
|
|
|
|
+ ValueTypeFruit[] items = {ValueTypeFruit.APPLE, ValueTypeFruit.BANANA, ValueTypeFruit.CHERRY, ValueTypeFruit.APPLE};
|
|
|
|
|
+
|
|
|
|
|
+ var r = new RingBuffer<ValueTypeFruit>(4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) r.set((uint)i, items[i]);
|
|
|
|
|
+ assert(r.count() == 4);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
|
|
+ ValueTypeFruit got;
|
|
|
|
|
+ assert(r.try_get((uint)i, out got));
|
|
|
|
|
+ assert(got == items[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/enum/series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/enum/series", () => {
|
|
|
|
|
+// ValueTypeFruit[] items = {ValueTypeFruit.APPLE, ValueTypeFruit.BANANA, ValueTypeFruit.CHERRY, ValueTypeFruit.APPLE};
|
|
|
|
|
+//
|
|
|
|
|
+// var s = new Series<ValueTypeFruit>();
|
|
|
|
|
+// foreach (ValueTypeFruit i in items) s.add(i);
|
|
|
|
|
+// assert(s.count() == 4);
|
|
|
|
|
+// var arr = s.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == items[i]);
|
|
|
|
|
+// assert(s.pop_start() == items[0]);
|
|
|
|
|
+// assert(s.count() == 3);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/enum/dictionary", () => {
|
|
|
|
|
+ ValueTypeFruit[] items = {ValueTypeFruit.APPLE, ValueTypeFruit.BANANA, ValueTypeFruit.CHERRY, ValueTypeFruit.APPLE};
|
|
|
|
|
+
|
|
|
|
|
+ var d = new Dictionary<ValueTypeFruit, string>();
|
|
|
|
|
+ d.set(items[0], "zero");
|
|
|
|
|
+ d.set(items[1], "one");
|
|
|
|
|
+ assert(d.length == 2);
|
|
|
|
|
+ string got;
|
|
|
|
|
+ assert(d.try_get(items[0], out got) && got == "zero");
|
|
|
|
|
+ assert(d.try_get(items[1], out got) && got == "one");
|
|
|
|
|
+ assert(d.has(items[0]));
|
|
|
|
|
+ assert(!d.has(items[2]));
|
|
|
|
|
+ d.set(items[0], "again");
|
|
|
|
|
+ assert(d.length == 2);
|
|
|
|
|
+ assert(d.try_get(items[0], out got) && got == "again");
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/enum/hash_set", () => {
|
|
|
|
|
+ ValueTypeFruit[] items = {ValueTypeFruit.APPLE, ValueTypeFruit.BANANA, ValueTypeFruit.CHERRY, ValueTypeFruit.APPLE};
|
|
|
|
|
+
|
|
|
|
|
+ var hs = new HashSet<ValueTypeFruit>();
|
|
|
|
|
+ assert(hs.add(items[0]));
|
|
|
|
|
+ assert(hs.add(items[1]));
|
|
|
|
|
+ assert(!hs.add(items[0]));
|
|
|
|
|
+ assert(hs.length == 2);
|
|
|
|
|
+ assert(hs.has(items[0]));
|
|
|
|
|
+ assert(hs.has(items[1]));
|
|
|
|
|
+ assert(!hs.has(items[2]));
|
|
|
|
|
+ ValueTypeFruit found;
|
|
|
|
|
+ assert(hs.try_find(items[1], out found) && found == items[1]);
|
|
|
|
|
+ hs.remove(items[0]);
|
|
|
|
|
+ assert(!hs.has(items[0]));
|
|
|
|
|
+ assert(hs.length == 1);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/enum/fifo", () => {
|
|
|
|
|
+ ValueTypeFruit[] items = {ValueTypeFruit.APPLE, ValueTypeFruit.BANANA, ValueTypeFruit.CHERRY, ValueTypeFruit.APPLE};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Fifo<ValueTypeFruit>();
|
|
|
|
|
+ foreach (ValueTypeFruit i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[0]);
|
|
|
|
|
+ for (int i = 0; i < 4; i++) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/enum/lifo", () => {
|
|
|
|
|
+ ValueTypeFruit[] items = {ValueTypeFruit.APPLE, ValueTypeFruit.BANANA, ValueTypeFruit.CHERRY, ValueTypeFruit.APPLE};
|
|
|
|
|
+
|
|
|
|
|
+ var q = new Lifo<ValueTypeFruit>();
|
|
|
|
|
+ foreach (ValueTypeFruit i in items) q.push(i);
|
|
|
|
|
+ assert(q.peek() == items[3]);
|
|
|
|
|
+ for (int i = 3; i >= 0; i--) assert(q.pop() == items[i]);
|
|
|
|
|
+ q.unblock();
|
|
|
|
|
+ try { q.pop(); assert_not_reached(); } catch (SequenceError e) { }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/enum/enumerable", () => {
|
|
|
|
|
+ ValueTypeFruit[] items = {ValueTypeFruit.APPLE, ValueTypeFruit.BANANA, ValueTypeFruit.CHERRY, ValueTypeFruit.APPLE};
|
|
|
|
|
+
|
|
|
|
|
+ var e = Wrap.array(items);
|
|
|
|
|
+ assert(e.count() == 4);
|
|
|
|
|
+ assert(e.select<ValueTypeFruit>(i => i).count() == 4);
|
|
|
|
|
+ assert(e.to_array().length == 4);
|
|
|
|
|
+ assert(e.to_vector().count() == 4);
|
|
|
|
|
+ assert(e.first() == items[0]);
|
|
|
|
|
+ assert(e.last() == items[3]);
|
|
|
|
|
+ assert(e.contains(items[2]));
|
|
|
|
|
+ var n = Wrap.array(items).aggregate<int>(0, (acc, i) => acc + 1);
|
|
|
|
|
+ assert(n == 4);
|
|
|
|
|
+ var uniq = Wrap.array(items).distinct().count();
|
|
|
|
|
+ assert(uniq == (items[0] == items[3] ? 3 : 4));
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/enum/priority_queue): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/enum/priority_queue", () => {
|
|
|
|
|
+// ValueTypeFruit[] items = {ValueTypeFruit.APPLE, ValueTypeFruit.BANANA, ValueTypeFruit.CHERRY, ValueTypeFruit.APPLE};
|
|
|
|
|
+// ValueTypeFruit[] sorted = {ValueTypeFruit.APPLE, ValueTypeFruit.APPLE, ValueTypeFruit.BANANA, ValueTypeFruit.CHERRY};
|
|
|
|
|
+//
|
|
|
|
|
+// var q = new PriorityQueue<ValueTypeFruit>((a, b) => Operators.comparison<ValueTypeFruit>()(a, b));
|
|
|
|
|
+// foreach (ValueTypeFruit i in items) q.push(i);
|
|
|
|
|
+// assert(q.count() == 4);
|
|
|
|
|
+// assert(q.peek() == sorted[0]);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(q.pop() == sorted[i]);
|
|
|
|
|
+// assert(q.count() == 0);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/enum/sorted_vector): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/enum/sorted_vector", () => {
|
|
|
|
|
+// ValueTypeFruit[] items = {ValueTypeFruit.APPLE, ValueTypeFruit.BANANA, ValueTypeFruit.CHERRY, ValueTypeFruit.APPLE};
|
|
|
|
|
+// ValueTypeFruit[] sorted = {ValueTypeFruit.APPLE, ValueTypeFruit.APPLE, ValueTypeFruit.BANANA, ValueTypeFruit.CHERRY};
|
|
|
|
|
+//
|
|
|
|
|
+// var sv = new SortedVector<ValueTypeFruit>();
|
|
|
|
|
+// foreach (ValueTypeFruit i in items) sv.add(i);
|
|
|
|
|
+// assert(sv.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
|
|
+// ValueTypeFruit got;
|
|
|
|
|
+// assert(sv.try_get((uint)i, out got));
|
|
|
|
|
+// assert(got == sorted[i]);
|
|
|
|
|
+// }
|
|
|
|
|
+// var sv2 = new SortedVector<ValueTypeFruit>();
|
|
|
|
|
+// sv2.add_all(Wrap.array(items));
|
|
|
|
|
+// assert(sv2.length == 4);
|
|
|
|
|
+// assert(sv2.get(0) == sorted[0]);
|
|
|
|
|
+// var srt = Wrap.array(items).sort(Operators.comparison<ValueTypeFruit>()).to_array();
|
|
|
|
|
+// assert(srt.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(srt[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ // BROKEN(/invercargill/value_type_matrix/enum/sorted_series): known failure at time of writing -- whole case disabled.
|
|
|
|
|
+ // Keep the original body below for the fix tasks to re-enable:
|
|
|
|
|
+// Test.add_func("/invercargill/value_type_matrix/enum/sorted_series", () => {
|
|
|
|
|
+// ValueTypeFruit[] items = {ValueTypeFruit.APPLE, ValueTypeFruit.BANANA, ValueTypeFruit.CHERRY, ValueTypeFruit.APPLE};
|
|
|
|
|
+// ValueTypeFruit[] sorted = {ValueTypeFruit.APPLE, ValueTypeFruit.APPLE, ValueTypeFruit.BANANA, ValueTypeFruit.CHERRY};
|
|
|
|
|
+//
|
|
|
|
|
+// var ss = new SortedSeries<ValueTypeFruit>();
|
|
|
|
|
+// foreach (ValueTypeFruit i in items) ss.add(i);
|
|
|
|
|
+// assert(ss.length == 4);
|
|
|
|
|
+// var arr = ss.to_array();
|
|
|
|
|
+// assert(arr.length == 4);
|
|
|
|
|
+// for (int i = 0; i < 4; i++) assert(arr[i] == sorted[i]);
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ Test.add_func("/invercargill/value_type_matrix/enum/operators", () => {
|
|
|
|
|
+ ValueTypeFruit[] items = {ValueTypeFruit.APPLE, ValueTypeFruit.BANANA, ValueTypeFruit.CHERRY, ValueTypeFruit.APPLE};
|
|
|
|
|
+
|
|
|
|
|
+ var eq = Operators.equality<ValueTypeFruit>();
|
|
|
|
|
+ assert(eq(items[0], items[0]));
|
|
|
|
|
+ assert(!eq(items[0], items[1]));
|
|
|
|
|
+ var st = Operators.stringify<ValueTypeFruit>();
|
|
|
|
|
+ assert(st(items[0]) != null && st(items[0]).length > 0);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void value_type_matrix_tests() {
|
|
|
|
|
+ value_type_matrix_bool_tests();
|
|
|
|
|
+ value_type_matrix_int_tests();
|
|
|
|
|
+ value_type_matrix_uint_tests();
|
|
|
|
|
+ value_type_matrix_long_tests();
|
|
|
|
|
+ value_type_matrix_ulong_tests();
|
|
|
|
|
+ value_type_matrix_int64_tests();
|
|
|
|
|
+ value_type_matrix_uint64_tests();
|
|
|
|
|
+ value_type_matrix_float_tests();
|
|
|
|
|
+ value_type_matrix_double_tests();
|
|
|
|
|
+ value_type_matrix_char_tests();
|
|
|
|
|
+ value_type_matrix_uchar_tests();
|
|
|
|
|
+ value_type_matrix_enum_tests();
|
|
|
|
|
+}
|