diff options
Diffstat (limited to 'tests/network/protocol/negotiation.c')
-rw-r--r-- | tests/network/protocol/negotiation.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/network/protocol/negotiation.c b/tests/network/protocol/negotiation.c new file mode 100644 index 000000000..0fa76a257 --- /dev/null +++ b/tests/network/protocol/negotiation.c @@ -0,0 +1,40 @@ +#include "clar_libgit2.h" +#include "transports/smart.h" + +static git_pkt *pkt; + +void test_network_protocol_negotiation__cleanup(void) +{ + git_pkt_free(pkt); + pkt = NULL; +} + +void test_network_protocol_negotiation__have(void) +{ + const char buf[] = "0032have 7e47fe2bd8d01d481f44d7af0531bd93d3b21c01\n"; + const char *rest; + git_oid id; + git_pkt_have_want *ppkt; + + git_oid_fromstr(&id, "7e47fe2bd8d01d481f44d7af0531bd93d3b21c01"); + + cl_git_pass(git_pkt_parse_line(&pkt, buf, &rest, sizeof(buf))); + cl_assert_equal_i(GIT_PKT_HAVE, pkt->type); + ppkt = (git_pkt_have_want *) pkt; + cl_assert(!git_oid_cmp(&id, &ppkt->id)); +} + +void test_network_protocol_negotiation__want(void) +{ + const char buf[] = "0032want 7e47fe2bd8d01d481f44d7af0531bd93d3b21c01\n"; + const char *rest; + git_oid id; + git_pkt_have_want *ppkt; + + git_oid_fromstr(&id, "7e47fe2bd8d01d481f44d7af0531bd93d3b21c01"); + + cl_git_pass(git_pkt_parse_line(&pkt, buf, &rest, sizeof(buf))); + cl_assert_equal_i(GIT_PKT_WANT, pkt->type); + ppkt = (git_pkt_have_want *) pkt; + cl_assert(!git_oid_cmp(&id, &ppkt->id)); +} |