diff options
Diffstat (limited to 'vespalib/src/tests/assert/asserter.cpp')
-rw-r--r-- | vespalib/src/tests/assert/asserter.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/vespalib/src/tests/assert/asserter.cpp b/vespalib/src/tests/assert/asserter.cpp new file mode 100644 index 00000000000..640464889c0 --- /dev/null +++ b/vespalib/src/tests/assert/asserter.cpp @@ -0,0 +1,25 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <vespa/vespalib/util/assert.h> +#include <cassert> +#include <cstdlib> +#include <fstream> +#include <string> + +int main(int argc, char *argv[]) { + assert(argc == 3); + const char * assertKey = argv[1]; + size_t assertCount = strtoul(argv[2], nullptr, 0); + for (size_t i(0); i < assertCount; i++) { + ASSERT_ONCE_OR_LOG(true, assertKey, 100); + ASSERT_ONCE_OR_LOG(false, assertKey, 100); + } + std::string filename = vespalib::assert::getAssertLogFileName(assertKey); + std::ifstream is(filename.c_str()); + assert(is); + std::string line; + std::getline(is, line); + printf("%s\n", filename.c_str()); + assert(line.find(assertKey) != std::string::npos); + assert(assertCount == vespalib::assert::getNumAsserts(assertKey)); + return 0; +} |