config: add tests for number suffix Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
diff --git a/tests/resources/config/config5 b/tests/resources/config/config5
new file mode 100644
index 0000000..645fe76
--- /dev/null
+++ b/tests/resources/config/config5
@@ -0,0 +1,6 @@
+# Test for number suffixes
+[number]
+ simple = 1
+ k = 1k
+ m = 1m
+ g = 1g
diff --git a/tests/t15-config.c b/tests/t15-config.c
index 2cbd058..1cf4b41 100644
--- a/tests/t15-config.c
+++ b/tests/t15-config.c
@@ -129,10 +129,34 @@ int i;
git_config_free(cfg);
END_TEST
+BEGIN_TEST(config5, "test number suffixes")
+ git_config *cfg;
+ const char *str;
+ long int i;
+
+ must_pass(git_config_open(&cfg, CONFIG_BASE "/config5"));
+
+ must_pass(git_config_get_long(cfg, "number.simple", &i));
+ must_be_true(i == 1);
+
+ must_pass(git_config_get_long(cfg, "number.k", &i));
+ must_be_true(i == 1 * 1024);
+
+ must_pass(git_config_get_long(cfg, "number.m", &i));
+ must_be_true(i == 1 * 1024 * 1024);
+
+ must_pass(git_config_get_long(cfg, "number.g", &i));
+ must_be_true(i == 1 * 1024 * 1024 * 1024);
+
+ git_config_free(cfg);
+END_TEST
+
+
BEGIN_SUITE(config)
ADD_TEST(config0);
ADD_TEST(config1);
ADD_TEST(config2);
ADD_TEST(config3);
ADD_TEST(config4);
+ ADD_TEST(config5);
END_SUITE