Char Array Unit Test: Introduce Convenience Type Alias
Mostly for shortening constructor calls. Suggested by: [at]atgeirr.
This commit is contained in:
parent
1695dfe78b
commit
20d0565220
@ -4,6 +4,10 @@
|
||||
|
||||
#include <opm/output/eclipse/CharArrayNullTerm.hpp>
|
||||
|
||||
// Convenience alias.
|
||||
template <std::size_t N>
|
||||
using AChar = ::Opm::RestartIO::Helpers::CharArrayNullTerm<N>;
|
||||
|
||||
// =====================================================================
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(AChar8)
|
||||
@ -12,21 +16,21 @@ BOOST_AUTO_TEST_CASE (Basic_Operations)
|
||||
{
|
||||
// Default Constructor
|
||||
{
|
||||
const auto s = Opm::RestartIO::Helpers::CharArrayNullTerm<8>{};
|
||||
const auto s = AChar<8>{};
|
||||
|
||||
BOOST_CHECK_EQUAL(s.c_str(), std::string(8, ' '));
|
||||
}
|
||||
|
||||
// Construct from Constant String
|
||||
{
|
||||
const auto s = Opm::RestartIO::Helpers::CharArrayNullTerm<8>{"Inj-1"};
|
||||
const auto s = AChar<8>{"Inj-1"};
|
||||
|
||||
BOOST_CHECK_EQUAL(s.c_str(), std::string{"Inj-1 "});
|
||||
}
|
||||
|
||||
// Copy Construction
|
||||
{
|
||||
const auto s1 = Opm::RestartIO::Helpers::CharArrayNullTerm<8>{"Inj-1"};
|
||||
const auto s1 = AChar<8>{"Inj-1"};
|
||||
const auto s2 = s1;
|
||||
|
||||
BOOST_CHECK_EQUAL(s2.c_str(), std::string{"Inj-1 "});
|
||||
@ -34,7 +38,7 @@ BOOST_AUTO_TEST_CASE (Basic_Operations)
|
||||
|
||||
// Move Construction
|
||||
{
|
||||
auto s1 = Opm::RestartIO::Helpers::CharArrayNullTerm<8>{"Inj-1"};
|
||||
auto s1 = AChar<8>{"Inj-1"};
|
||||
const auto s2 = std::move(s1);
|
||||
|
||||
BOOST_CHECK_EQUAL(s2.c_str(), std::string{"Inj-1 "});
|
||||
@ -42,8 +46,8 @@ BOOST_AUTO_TEST_CASE (Basic_Operations)
|
||||
|
||||
// Assignment Operator
|
||||
{
|
||||
const auto s1 = Opm::RestartIO::Helpers::CharArrayNullTerm<8>{"Inj-1"};
|
||||
auto s2 = Opm::RestartIO::Helpers::CharArrayNullTerm<8>{"Prod-2"};
|
||||
const auto s1 = AChar<8>{"Inj-1"};
|
||||
auto s2 = AChar<8>{"Prod-2"};
|
||||
|
||||
s2 = s1;
|
||||
BOOST_CHECK_EQUAL(s2.c_str(), std::string{"Inj-1 "});
|
||||
@ -51,8 +55,8 @@ BOOST_AUTO_TEST_CASE (Basic_Operations)
|
||||
|
||||
// Move Assignment Operator
|
||||
{
|
||||
auto s1 = Opm::RestartIO::Helpers::CharArrayNullTerm<8>{"Inj-1"};
|
||||
auto s2 = Opm::RestartIO::Helpers::CharArrayNullTerm<8>{"Prod-2"};
|
||||
auto s1 = AChar<8>{"Inj-1"};
|
||||
auto s2 = AChar<8>{"Prod-2"};
|
||||
|
||||
s2 = std::move(s1);
|
||||
BOOST_CHECK_EQUAL(s2.c_str(), std::string{"Inj-1 "});
|
||||
@ -60,7 +64,7 @@ BOOST_AUTO_TEST_CASE (Basic_Operations)
|
||||
|
||||
// Assign std::string
|
||||
{
|
||||
auto s = Opm::RestartIO::Helpers::CharArrayNullTerm<8>{"@Hi Hoo@"};
|
||||
auto s = AChar<8>{"@Hi Hoo@"};
|
||||
|
||||
s = "Prod-2";
|
||||
BOOST_CHECK_EQUAL(s.c_str(), std::string{"Prod-2 "});
|
||||
@ -71,7 +75,7 @@ BOOST_AUTO_TEST_CASE (String_Shortening)
|
||||
{
|
||||
// Construct from string of more than N characters
|
||||
{
|
||||
const auto s = Opm::RestartIO::Helpers::CharArrayNullTerm<10>{
|
||||
const auto s = AChar<10>{
|
||||
"String too long"
|
||||
};
|
||||
|
||||
@ -80,7 +84,7 @@ BOOST_AUTO_TEST_CASE (String_Shortening)
|
||||
|
||||
// Assign string of more than N characters
|
||||
{
|
||||
auto s = Opm::RestartIO::Helpers::CharArrayNullTerm<11>{};
|
||||
auto s = AChar<11>{};
|
||||
|
||||
s = "This string has too many characters";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user