diff options
author | Benjamin Segovia <segovia.benjamin@gmail.com> | 2012-05-03 15:14:53 +0000 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-08-10 16:16:57 -0700 |
commit | 1a9bcd8ff623a0b96cb034df711e4b02bfab8c6e (patch) | |
tree | bb3085d39b10c5ca759466675f7c648cafd6fc4d /utests/utest_assert.cpp | |
parent | 97c10d0a80665562cd4980fa9a8b4e5a52750f3a (diff) | |
download | beignet-1a9bcd8ff623a0b96cb034df711e4b02bfab8c6e.tar.gz |
tests -> utests
Diffstat (limited to 'utests/utest_assert.cpp')
-rw-r--r-- | utests/utest_assert.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/utests/utest_assert.cpp b/utests/utest_assert.cpp new file mode 100644 index 00000000..da656e8d --- /dev/null +++ b/utests/utest_assert.cpp @@ -0,0 +1,42 @@ +/* + * Copyright © 2012 Intel Corporation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + * Author: Benjamin Segovia <benjamin.segovia@intel.com> + */ + +/** + * \file assert.cpp + * \author Benjamin Segovia <benjamin.segovia@intel.com> + */ +#include "utest_assert.hpp" +#include "utest_exception.hpp" +#include <cassert> +#include <cstdlib> + +void onFailedAssertion(const char *msg, const char *file, const char *fn, int line) +{ + char lineString[256]; + sprintf(lineString, "%i", line); + assert(msg != NULL && file != NULL && fn != NULL); + const std::string str = "Compiler error: " + + std::string(msg) + "\n at file " + + std::string(file) + + ", function " + std::string(fn) + + ", line " + std::string(lineString); + // assert(0); + throw Exception(str); +} + |