X Tutup
Skip to content

Commit d68e99e

Browse files
author
Sebastiano Merlino
committed
Added some tests for http_utils sublib
1 parent a47c3e0 commit d68e99e

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

test/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
LDADD = $(top_builddir)/src/libhttpserver.la
2020
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/httpserver/
2121
METASOURCES = AUTO
22-
check_PROGRAMS = basic
22+
check_PROGRAMS = basic http_utils
2323

2424
basic_SOURCES = integ/basic.cpp
25+
http_utils_SOURCES = unit/http_utils_test.cpp
2526

2627
noinst_HEADERS = littletest.hpp
2728
AM_CXXFLAGS += -lcurl -Wall -fPIC

test/unit/http_utils_test.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
This file is part of libhttpserver
3+
Copyright (C) 2011, 2012, 2013, 2014 Sebastiano Merlino
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18+
USA
19+
*/
20+
21+
#include "littletest.hpp"
22+
#include "http_utils.hpp"
23+
#include <cstdio>
24+
25+
using namespace httpserver;
26+
using namespace std;
27+
28+
LT_BEGIN_SUITE(http_utils_suite)
29+
void set_up()
30+
{
31+
}
32+
33+
void tear_down()
34+
{
35+
}
36+
LT_END_SUITE(http_utils_suite)
37+
38+
LT_BEGIN_AUTO_TEST(http_utils_suite, unescape)
39+
char* string_with_plus = (char*) malloc(5 * sizeof(char));
40+
sprintf(string_with_plus, "%s", "A%20B");
41+
int expected_size = http::http_unescape(string_with_plus);
42+
43+
char* expected = (char*) malloc(3 * sizeof(char));
44+
sprintf(expected, "%s", "A B");
45+
46+
LT_CHECK_EQ(string(string_with_plus), string(expected));
47+
LT_CHECK_EQ(expected_size, 3);
48+
LT_END_AUTO_TEST(unescape)
49+
50+
LT_BEGIN_AUTO_TEST_ENV()
51+
AUTORUN_TESTS()
52+
LT_END_AUTO_TEST_ENV()

0 commit comments

Comments
 (0)
X Tutup