diff options
Diffstat (limited to 'libcxx/test/std/diagnostics/std.exceptions')
10 files changed, 398 insertions, 0 deletions
diff --git a/libcxx/test/std/diagnostics/std.exceptions/domain.error/domain_error.pass.cpp b/libcxx/test/std/diagnostics/std.exceptions/domain.error/domain_error.pass.cpp new file mode 100644 index 00000000000..5769d250537 --- /dev/null +++ b/libcxx/test/std/diagnostics/std.exceptions/domain.error/domain_error.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test domain_error + +#include <stdexcept> +#include <type_traits> +#include <cstring> +#include <string> +#include <cassert> + +int main() +{ + static_assert((std::is_base_of<std::logic_error, std::domain_error>::value), + "std::is_base_of<std::logic_error, std::domain_error>::value"); + static_assert(std::is_polymorphic<std::domain_error>::value, + "std::is_polymorphic<std::domain_error>::value"); + { + const char* msg = "domain_error message"; + std::domain_error e(msg); + assert(std::strcmp(e.what(), msg) == 0); + std::domain_error e2(e); + assert(std::strcmp(e2.what(), msg) == 0); + e2 = e; + assert(std::strcmp(e2.what(), msg) == 0); + } + { + std::string msg("another domain_error message"); + std::domain_error e(msg); + assert(e.what() == msg); + std::domain_error e2(e); + assert(e2.what() == msg); + e2 = e; + assert(e2.what() == msg); + } +} diff --git a/libcxx/test/std/diagnostics/std.exceptions/invalid.argument/invalid_argument.pass.cpp b/libcxx/test/std/diagnostics/std.exceptions/invalid.argument/invalid_argument.pass.cpp new file mode 100644 index 00000000000..e360275a683 --- /dev/null +++ b/libcxx/test/std/diagnostics/std.exceptions/invalid.argument/invalid_argument.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test invalid_argument + +#include <stdexcept> +#include <type_traits> +#include <cstring> +#include <string> +#include <cassert> + +int main() +{ + static_assert((std::is_base_of<std::logic_error, std::invalid_argument>::value), + "std::is_base_of<std::logic_error, std::invalid_argument>::value"); + static_assert(std::is_polymorphic<std::invalid_argument>::value, + "std::is_polymorphic<std::invalid_argument>::value"); + { + const char* msg = "invalid_argument message"; + std::invalid_argument e(msg); + assert(std::strcmp(e.what(), msg) == 0); + std::invalid_argument e2(e); + assert(std::strcmp(e2.what(), msg) == 0); + e2 = e; + assert(std::strcmp(e2.what(), msg) == 0); + } + { + std::string msg("another invalid_argument message"); + std::invalid_argument e(msg); + assert(e.what() == msg); + std::invalid_argument e2(e); + assert(e2.what() == msg); + e2 = e; + assert(e2.what() == msg); + } +} diff --git a/libcxx/test/std/diagnostics/std.exceptions/length.error/length_error.pass.cpp b/libcxx/test/std/diagnostics/std.exceptions/length.error/length_error.pass.cpp new file mode 100644 index 00000000000..3a9144121a0 --- /dev/null +++ b/libcxx/test/std/diagnostics/std.exceptions/length.error/length_error.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test length_error + +#include <stdexcept> +#include <type_traits> +#include <cstring> +#include <string> +#include <cassert> + +int main() +{ + static_assert((std::is_base_of<std::logic_error, std::length_error>::value), + "std::is_base_of<std::logic_error, std::length_error>::value"); + static_assert(std::is_polymorphic<std::length_error>::value, + "std::is_polymorphic<std::length_error>::value"); + { + const char* msg = "length_error message"; + std::length_error e(msg); + assert(std::strcmp(e.what(), msg) == 0); + std::length_error e2(e); + assert(std::strcmp(e2.what(), msg) == 0); + e2 = e; + assert(std::strcmp(e2.what(), msg) == 0); + } + { + std::string msg("another length_error message"); + std::length_error e(msg); + assert(e.what() == msg); + std::length_error e2(e); + assert(e2.what() == msg); + e2 = e; + assert(e2.what() == msg); + } +} diff --git a/libcxx/test/std/diagnostics/std.exceptions/logic.error/logic_error.pass.cpp b/libcxx/test/std/diagnostics/std.exceptions/logic.error/logic_error.pass.cpp new file mode 100644 index 00000000000..3c3d4f4f971 --- /dev/null +++ b/libcxx/test/std/diagnostics/std.exceptions/logic.error/logic_error.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test logic_error + +#include <stdexcept> +#include <type_traits> +#include <cstring> +#include <string> +#include <cassert> + +int main() +{ + static_assert((std::is_base_of<std::exception, std::logic_error>::value), + "std::is_base_of<std::exception, std::logic_error>::value"); + static_assert(std::is_polymorphic<std::logic_error>::value, + "std::is_polymorphic<std::logic_error>::value"); + { + const char* msg = "logic_error message"; + std::logic_error e(msg); + assert(std::strcmp(e.what(), msg) == 0); + std::logic_error e2(e); + assert(std::strcmp(e2.what(), msg) == 0); + e2 = e; + assert(std::strcmp(e2.what(), msg) == 0); + } + { + std::string msg("another logic_error message"); + std::logic_error e(msg); + assert(e.what() == msg); + std::logic_error e2(e); + assert(e2.what() == msg); + e2 = e; + assert(e2.what() == msg); + } +} diff --git a/libcxx/test/std/diagnostics/std.exceptions/out.of.range/out_of_range.pass.cpp b/libcxx/test/std/diagnostics/std.exceptions/out.of.range/out_of_range.pass.cpp new file mode 100644 index 00000000000..f358d2b7652 --- /dev/null +++ b/libcxx/test/std/diagnostics/std.exceptions/out.of.range/out_of_range.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test out_of_range + +#include <stdexcept> +#include <type_traits> +#include <cstring> +#include <string> +#include <cassert> + +int main() +{ + static_assert((std::is_base_of<std::logic_error, std::out_of_range>::value), + "std::is_base_of<std::logic_error, std::out_of_range>::value"); + static_assert(std::is_polymorphic<std::out_of_range>::value, + "std::is_polymorphic<std::out_of_range>::value"); + { + const char* msg = "out_of_range message"; + std::out_of_range e(msg); + assert(std::strcmp(e.what(), msg) == 0); + std::out_of_range e2(e); + assert(std::strcmp(e2.what(), msg) == 0); + e2 = e; + assert(std::strcmp(e2.what(), msg) == 0); + } + { + std::string msg("another out_of_range message"); + std::out_of_range e(msg); + assert(e.what() == msg); + std::out_of_range e2(e); + assert(e2.what() == msg); + e2 = e; + assert(e2.what() == msg); + } +} diff --git a/libcxx/test/std/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp b/libcxx/test/std/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp new file mode 100644 index 00000000000..47f75eb0f39 --- /dev/null +++ b/libcxx/test/std/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test overflow_error + +#include <stdexcept> +#include <type_traits> +#include <cstring> +#include <string> +#include <cassert> + +int main() +{ + static_assert((std::is_base_of<std::runtime_error, std::overflow_error>::value), + "std::is_base_of<std::runtime_error, std::overflow_error>::value"); + static_assert(std::is_polymorphic<std::overflow_error>::value, + "std::is_polymorphic<std::overflow_error>::value"); + { + const char* msg = "overflow_error message"; + std::overflow_error e(msg); + assert(std::strcmp(e.what(), msg) == 0); + std::overflow_error e2(e); + assert(std::strcmp(e2.what(), msg) == 0); + e2 = e; + assert(std::strcmp(e2.what(), msg) == 0); + } + { + std::string msg("another overflow_error message"); + std::overflow_error e(msg); + assert(e.what() == msg); + std::overflow_error e2(e); + assert(e2.what() == msg); + e2 = e; + assert(e2.what() == msg); + } +} diff --git a/libcxx/test/std/diagnostics/std.exceptions/range.error/range_error.pass.cpp b/libcxx/test/std/diagnostics/std.exceptions/range.error/range_error.pass.cpp new file mode 100644 index 00000000000..8c82a918921 --- /dev/null +++ b/libcxx/test/std/diagnostics/std.exceptions/range.error/range_error.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test range_error + +#include <stdexcept> +#include <type_traits> +#include <cstring> +#include <string> +#include <cassert> + +int main() +{ + static_assert((std::is_base_of<std::runtime_error, std::range_error>::value), + "std::is_base_of<std::runtime_error, std::range_error>::value"); + static_assert(std::is_polymorphic<std::range_error>::value, + "std::is_polymorphic<std::range_error>::value"); + { + const char* msg = "range_error message"; + std::range_error e(msg); + assert(std::strcmp(e.what(), msg) == 0); + std::range_error e2(e); + assert(std::strcmp(e2.what(), msg) == 0); + e2 = e; + assert(std::strcmp(e2.what(), msg) == 0); + } + { + std::string msg("another range_error message"); + std::range_error e(msg); + assert(e.what() == msg); + std::range_error e2(e); + assert(e2.what() == msg); + e2 = e; + assert(e2.what() == msg); + } +} diff --git a/libcxx/test/std/diagnostics/std.exceptions/runtime.error/runtime_error.pass.cpp b/libcxx/test/std/diagnostics/std.exceptions/runtime.error/runtime_error.pass.cpp new file mode 100644 index 00000000000..2b2fe20c662 --- /dev/null +++ b/libcxx/test/std/diagnostics/std.exceptions/runtime.error/runtime_error.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test runtime_error + +#include <stdexcept> +#include <type_traits> +#include <cstring> +#include <string> +#include <cassert> + +int main() +{ + static_assert((std::is_base_of<std::exception, std::runtime_error>::value), + "std::is_base_of<std::exception, std::runtime_error>::value"); + static_assert(std::is_polymorphic<std::runtime_error>::value, + "std::is_polymorphic<std::runtime_error>::value"); + { + const char* msg = "runtime_error message"; + std::runtime_error e(msg); + assert(std::strcmp(e.what(), msg) == 0); + std::runtime_error e2(e); + assert(std::strcmp(e2.what(), msg) == 0); + e2 = e; + assert(std::strcmp(e2.what(), msg) == 0); + } + { + std::string msg("another runtime_error message"); + std::runtime_error e(msg); + assert(e.what() == msg); + std::runtime_error e2(e); + assert(e2.what() == msg); + e2 = e; + assert(e2.what() == msg); + } +} diff --git a/libcxx/test/std/diagnostics/std.exceptions/underflow.error/underflow_error.pass.cpp b/libcxx/test/std/diagnostics/std.exceptions/underflow.error/underflow_error.pass.cpp new file mode 100644 index 00000000000..103c290ac40 --- /dev/null +++ b/libcxx/test/std/diagnostics/std.exceptions/underflow.error/underflow_error.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test underflow_error + +#include <stdexcept> +#include <type_traits> +#include <cstring> +#include <string> +#include <cassert> + +int main() +{ + static_assert((std::is_base_of<std::runtime_error, std::underflow_error>::value), + "std::is_base_of<std::runtime_error, std::underflow_error>::value"); + static_assert(std::is_polymorphic<std::underflow_error>::value, + "std::is_polymorphic<std::underflow_error>::value"); + { + const char* msg = "underflow_error message"; + std::underflow_error e(msg); + assert(std::strcmp(e.what(), msg) == 0); + std::underflow_error e2(e); + assert(std::strcmp(e2.what(), msg) == 0); + e2 = e; + assert(std::strcmp(e2.what(), msg) == 0); + } + { + std::string msg("another underflow_error message"); + std::underflow_error e(msg); + assert(e.what() == msg); + std::underflow_error e2(e); + assert(e2.what() == msg); + e2 = e; + assert(e2.what() == msg); + } +} diff --git a/libcxx/test/std/diagnostics/std.exceptions/version.pass.cpp b/libcxx/test/std/diagnostics/std.exceptions/version.pass.cpp new file mode 100644 index 00000000000..d9ab009a436 --- /dev/null +++ b/libcxx/test/std/diagnostics/std.exceptions/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <stdexcept> + +#include <stdexcept> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} |