summaryrefslogtreecommitdiff
path: root/tests/config/read.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/config/read.c')
-rw-r--r--tests/config/read.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/tests/config/read.c b/tests/config/read.c
index 8d1bb8b0a..77f8a1262 100644
--- a/tests/config/read.c
+++ b/tests/config/read.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "path.h"
static git_buf buf = GIT_BUF_INIT;
@@ -36,11 +35,11 @@ void test_config_read__case_sensitive(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config1")));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "this.that.other"));
- cl_assert_equal_s("true", git_buf_cstr(&buf));
- git_buf_clear(&buf);
+ cl_assert_equal_s("true", buf.ptr);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "this.That.other"));
- cl_assert_equal_s("yes", git_buf_cstr(&buf));
+ cl_assert_equal_s("yes", buf.ptr);
cl_git_pass(git_config_get_bool(&i, cfg, "this.that.other"));
cl_assert(i == 1);
@@ -64,7 +63,7 @@ void test_config_read__multiline_value(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config2")));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "this.That.and"));
- cl_assert_equal_s("one one one two two three three", git_buf_cstr(&buf));
+ cl_assert_equal_s("one one one two two three three", buf.ptr);
git_config_free(cfg);
}
@@ -84,7 +83,7 @@ void test_config_read__multiline_value_and_eof(void)
cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "header.key1"));
- cl_assert_equal_s("foo", git_buf_cstr(&buf));
+ cl_assert_equal_s("foo", buf.ptr);
git_config_free(cfg);
}
@@ -98,7 +97,7 @@ void test_config_read__multiline_eof(void)
cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "header.key1"));
- cl_assert_equal_s("", git_buf_cstr(&buf));
+ cl_assert_equal_s("", buf.ptr);
git_config_free(cfg);
}
@@ -113,7 +112,7 @@ void test_config_read__subsection_header(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config3")));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "section.subsection.var"));
- cl_assert_equal_s("hello", git_buf_cstr(&buf));
+ cl_assert_equal_s("hello", buf.ptr);
/* The subsection is transformed to lower-case */
cl_must_fail(git_config_get_string_buf(&buf, cfg, "section.subSectIon.var"));
@@ -131,14 +130,14 @@ void test_config_read__lone_variable(void)
cl_git_fail(git_config_get_int32(&i, cfg, "some.section.variable"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.section.variable"));
- cl_assert_equal_s("", git_buf_cstr(&buf));
- git_buf_clear(&buf);
+ cl_assert_equal_s("", buf.ptr);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_bool(&i, cfg, "some.section.variable"));
cl_assert(i == 1);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.section.variableeq"));
- cl_assert_equal_s("", git_buf_cstr(&buf));
+ cl_assert_equal_s("", buf.ptr);
cl_git_pass(git_config_get_bool(&i, cfg, "some.section.variableeq"));
cl_assert(i == 0);
@@ -234,11 +233,11 @@ void test_config_read__prefixes(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config9")));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "remote.ab.url"));
- cl_assert_equal_s("http://example.com/git/ab", git_buf_cstr(&buf));
- git_buf_clear(&buf);
+ cl_assert_equal_s("http://example.com/git/ab", buf.ptr);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "remote.abba.url"));
- cl_assert_equal_s("http://example.com/git/abba", git_buf_cstr(&buf));
+ cl_assert_equal_s("http://example.com/git/abba", buf.ptr);
git_config_free(cfg);
}
@@ -249,7 +248,7 @@ void test_config_read__escaping_quotes(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config13")));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "core.editor"));
- cl_assert_equal_s("\"C:/Program Files/Nonsense/bah.exe\" \"--some option\"", git_buf_cstr(&buf));
+ cl_assert_equal_s("\"C:/Program Files/Nonsense/bah.exe\" \"--some option\"", buf.ptr);
git_config_free(cfg);
}
@@ -446,11 +445,11 @@ void test_config_read__whitespace_not_required_around_assignment(void)
cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config14")));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "a.b"));
- cl_assert_equal_s("c", git_buf_cstr(&buf));
- git_buf_clear(&buf);
+ cl_assert_equal_s("c", buf.ptr);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "d.e"));
- cl_assert_equal_s("f", git_buf_cstr(&buf));
+ cl_assert_equal_s("f", buf.ptr);
git_config_free(cfg);
}
@@ -596,7 +595,7 @@ void test_config_read__simple_read_from_specific_level(void)
cl_git_pass(git_config_get_bool(&i, cfg_specific, "core.boolglobal"));
cl_assert_equal_b(true, i);
cl_git_pass(git_config_get_string_buf(&buf, cfg_specific, "core.stringglobal"));
- cl_assert_equal_s("I'm a global config value!", git_buf_cstr(&buf));
+ cl_assert_equal_s("I'm a global config value!", buf.ptr);
git_config_free(cfg_specific);
git_config_free(cfg);
@@ -692,7 +691,7 @@ void test_config_read__override_variable(void)
cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig"));
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.var"));
- cl_assert_equal_s("two", git_buf_cstr(&buf));
+ cl_assert_equal_s("two", buf.ptr);
git_config_free(cfg);
}
@@ -702,8 +701,8 @@ void test_config_read__path(void)
git_config *cfg;
git_buf path = GIT_BUF_INIT;
git_buf old_path = GIT_BUF_INIT;
- git_buf home_path = GIT_BUF_INIT;
- git_buf expected_path = GIT_BUF_INIT;
+ git_str home_path = GIT_STR_INIT;
+ git_str expected_path = GIT_STR_INIT;
cl_git_pass(p_mkdir("fakehome", 0777));
cl_git_pass(git_path_prettify(&home_path, "fakehome", NULL));
@@ -725,7 +724,7 @@ void test_config_read__path(void)
git_buf_dispose(&path);
cl_git_mkfile("./testconfig", "[some]\n path = ~");
- cl_git_pass(git_buf_sets(&expected_path, home_path.ptr));
+ cl_git_pass(git_str_sets(&expected_path, home_path.ptr));
cl_git_pass(git_config_get_path(&path, cfg, "some.path"));
cl_assert_equal_s(expected_path.ptr, path.ptr);
@@ -736,8 +735,8 @@ void test_config_read__path(void)
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, old_path.ptr));
git_buf_dispose(&old_path);
- git_buf_dispose(&home_path);
- git_buf_dispose(&expected_path);
+ git_str_dispose(&home_path);
+ git_str_dispose(&expected_path);
git_config_free(cfg);
}
@@ -884,18 +883,18 @@ void test_config_read__single_line(void)
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.var"));
cl_assert_equal_s(buf.ptr, "value");
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.OtheR.var"));
cl_assert_equal_s(buf.ptr, "value");
git_config_free(cfg);
cl_git_mkfile("./testconfig", "[some] var = value\n[some \"OtheR\"]var = value");
cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig"));
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.var"));
cl_assert_equal_s(buf.ptr, "value");
- git_buf_clear(&buf);
+ git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, cfg, "some.OtheR.var"));
cl_assert_equal_s(buf.ptr, "value");