|
| 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