Commit 53345e1f1fedf63f8d21b5c2959ae6bca3dabde1

Carlos Martín Nieto 2011-04-11T18:01:01

config: add tests for number suffix Signed-off-by: Carlos Martín Nieto <cmn@elego.de>

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