text
stringlengths
0
2.2M
s.reset();
if (verbose) {
cout << "Time to aquire " << NUM_ITERATIONS << " random ints: "
<< time << endl;
}
} break;
default: {
cerr << "WARNING: CASE `" << test << "' NOT FOUND." << endl;
testStatus = -1;
} break;
}
if (testStatus > 0) {
cerr << "Error, non-zero test status = " << testStatus << "." << endl;
}
return testStatus;
}
// ----------------------------------------------------------------------------
// Copyright 2014 Bloomberg Finance L.P.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------- END-OF-FILE ----------------------------------
// Copyright (C) 2012 Davis E. King ([email protected])
// License: Boost Software License See LICENSE.txt for the full license.
#include <dlib/vectorstream.h>
#include <sstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <vector>
#include "tester.h"
namespace
{
using namespace test;
using namespace dlib;
using namespace std;
logger dlog("test.vectorstream");
template <typename CharType, typename stream>
void test1_variant(std::vector<CharType>& buf, stream& s)
{
for (int i = -1000; i <= 1000; ++i)
{
char ch = i;
s.put(ch);
}
DLIB_TEST(buf.size() == 2001);
int cnt = -1000;
for (unsigned long i = 0; i < buf.size(); ++i)
{
char ch = cnt;
DLIB_TEST((char)buf[i] == ch);
++cnt;
}
for (int i = -1000; i <= 1000; ++i)
{
DLIB_TEST(s.peek() != EOF);
char ch1 = i;
char ch2 = s.get();
DLIB_TEST(ch1 == ch2);
}
DLIB_TEST(s.peek() == EOF);
DLIB_TEST(s.get() == EOF);
s.clear();
s.seekg(6); //Let iostream decide which path to take. In theory it could decide to use any.
for (int i = -1000+6; i <= 1000; ++i)
{
DLIB_TEST(s.peek() != EOF);
char ch1 = i;
char ch2 = s.get();
DLIB_TEST(ch1 == ch2);
}
DLIB_TEST(s.peek() == EOF);