blob: 1c0ed7ffcb51dec5ad2b4d3ee80fed276fef0e10 (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#define BOOST_TEST_MODULE Curl
#include <boost/test/unit_test.hpp>
#include "curlHandle.h"
#include "curlStream.h"
#include "definedDirs.h"
#include "net.h"
size_t discard(void *, size_t sz, size_t nm, void *)
{
return sz * nm;
}
BOOST_AUTO_TEST_CASE( fetch_file )
{
auto url = "file://" + RootDir.string() + "/testCurl.cpp";
CurlHandle ch(url);
ch.setopt(CURLOPT_WRITEFUNCTION, (void*)&discard);
ch.perform();
}
BOOST_AUTO_TEST_CASE( fetch_missing )
{
auto url = "file://" + RootDir.string() + "/nothere";
CurlHandle ch(url);
BOOST_REQUIRE_THROW(ch.perform(), AdHoc::Net::CurlException);
}
BOOST_AUTO_TEST_CASE( fetch_file_stream )
{
auto url = "file://" + RootDir.string() + "/testCurl.cpp";
CurlStreamSource css(url);
boost::iostreams::stream<css_ref> curlstrm(boost::ref(css));
std::string tok;
curlstrm >> tok;
BOOST_REQUIRE_EQUAL("#define", tok);
curlstrm >> tok;
BOOST_REQUIRE_EQUAL("BOOST_TEST_MODULE", tok);
curlstrm >> tok;
BOOST_REQUIRE_EQUAL("Curl", tok);
while (!curlstrm.eof()) {
curlstrm >> tok;
}
}
BOOST_AUTO_TEST_CASE( fetch_missing_stream )
{
auto url = "file://" + RootDir.string() + "/nothere";
BOOST_REQUIRE_THROW({
CurlStreamSource css(url);
boost::iostreams::stream<css_ref> curlstrm(boost::ref(css));
std::string tok;
curlstrm >> tok;
}, AdHoc::Net::CurlException);
}
|