From 388eb36ecb0c083e1d36812ecf541f9d85441f73 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 30 Jun 2019 13:44:08 +0200 Subject: [PATCH] map_test.v --- vlib/builtin/map_test.v | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 vlib/builtin/map_test.v diff --git a/vlib/builtin/map_test.v b/vlib/builtin/map_test.v new file mode 100644 index 0000000000..06cc7ecc42 --- /dev/null +++ b/vlib/builtin/map_test.v @@ -0,0 +1,21 @@ +struct A { + m map_int +} + +fn (a mut A) set(key string, val int) { + a.m[key] = val +} + +fn test_map() { + mut m := map[string]int{} + m['hi'] = 80 + assert m['hi'] == 80 + + mut a := A{ + m: new_map(1, sizeof(int)) + } + a.m['one'] = 1 + a.set('two', 2) + assert a.m['one'] == 1 + assert a.m['two'] == 2 +}