From 6ed9e59db7a4c2d54079f2f33e5e78aacd068b7b Mon Sep 17 00:00:00 2001 From: josephjaspers Date: Mon, 27 Apr 2020 07:02:51 -0700 Subject: [PATCH] Add more tests for issue #65, tests are passing though --- blackcat/allocators/basic_allocators.h | 5 +++++ blackcat/common.h | 2 +- tests/test_algorithms.h | 8 +++----- tests/test_common.h | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/blackcat/allocators/basic_allocators.h b/blackcat/allocators/basic_allocators.h index 8908d2e0..74f62db0 100644 --- a/blackcat/allocators/basic_allocators.h +++ b/blackcat/allocators/basic_allocators.h @@ -24,7 +24,12 @@ struct Basic_Allocator_Base using value_type = ValueType; using pointer = value_type*; using const_pointer = value_type*; +#ifndef _MSC_VER + using size_type = std::size_t; +#else + //Custom allocators with signed types causes runtime exception inside of MSVC using size_type = int; +#endif using reference = value_type&; using const_reference = const value_type&; using propagate_on_container_copy_assignment = std::false_type; diff --git a/blackcat/common.h b/blackcat/common.h index 3c2c0328..d5c89e88 100644 --- a/blackcat/common.h +++ b/blackcat/common.h @@ -111,7 +111,7 @@ using default_system_tag_t = BC_DEFAULT_SYSTEM_TAG; // Visual Studio #ifdef _MSC_VER -#define __PRETTY_FUNCTION__ __FUNCTION__ +#define __PRETTY_FUNCTION__ __FUNCSIG__ #endif #include diff --git a/tests/test_algorithms.h b/tests/test_algorithms.h index 801bf512..f86289c0 100644 --- a/tests/test_algorithms.h +++ b/tests/test_algorithms.h @@ -72,9 +72,9 @@ int test_algorithms(int sz=128) { b.get_stream().sync(); return bc::tensors::all(a == 5) && bc::tensors::all(b == 7); - ) + ) - //TEST algo copy + //TEST algo copy BC_TEST_DEF( vec a(sz); std::vector b(sz); @@ -84,9 +84,7 @@ int test_algorithms(int sz=128) { host_b.push_back(i); dyn_b.push_back(i); } - - - bc::utility::Utility::copy(b.data(), host_b.data(), sz); + bc::utility::Utility::HostToDevice(b.data(), host_b.data(), sz); bc::copy(a.get_stream(), b.begin(), b.end(), a.cw_begin()); return bc::tensors::all(a.approx_equal(dyn_b)); ) diff --git a/tests/test_common.h b/tests/test_common.h index d1247892..968ed3b8 100644 --- a/tests/test_common.h +++ b/tests/test_common.h @@ -52,8 +52,8 @@ static std::string sz60_test_buffer() { } else { \ bc::print(sz80_substring("test success: "#__VA_ARGS__)); \ } \ - } catch (...) { \ - bc::print(sz80_substring("TEST ERROR: "#__VA_ARGS__)); \ + } catch (std::exception &e) { \ + bc::print(sz80_substring("TEST ERROR: " + std::string(e.what()) + #__VA_ARGS__)); \ bc_test_num_errors++; \ } \ }