summaryrefslogtreecommitdiff
path: root/tests/network/remote/isvalidname.c
blob: a3080f67c038439f24e2bf20df9ac39dde2773be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "clar_libgit2.h"

static int is_valid_name(const char *name)
{
	int valid = 0;
	cl_git_pass(git_remote_name_is_valid(&valid, name));
	return valid;
}

void test_network_remote_isvalidname__can_detect_invalid_formats(void)
{
	cl_assert_equal_i(false, is_valid_name("/"));
	cl_assert_equal_i(false, is_valid_name("//"));
	cl_assert_equal_i(false, is_valid_name(".lock"));
	cl_assert_equal_i(false, is_valid_name("a.lock"));
	cl_assert_equal_i(false, is_valid_name("/no/leading/slash"));
	cl_assert_equal_i(false, is_valid_name("no/trailing/slash/"));
}

void test_network_remote_isvalidname__wont_hopefully_choke_on_valid_formats(void)
{
	cl_assert_equal_i(true, is_valid_name("webmatrix"));
	cl_assert_equal_i(true, is_valid_name("yishaigalatzer/rules"));
}