/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code 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 General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
ASSERT_EQ(flags[0].is_default(), true) << "should be default";
ASSERT_EQ(!flags[1].is_default() && !flags[1], true) << "should be not default and not set";
ASSERT_EQ(!flags[2].is_default() && flags[2], true) << "should be not default and set";
ASSERT_EQ(flags[3].is_default() == true, true) << "should be default";
}
template <size_t SZ, typename T> struct Tester { staticvoid doit() { // test fill_in(value)
control_words.fill_in(TriBool()); for (size_t i = 0; i < SZ; ++i) {
EXPECT_TRUE(control_words[i].is_default());
}
TriBool F = false;
control_words.fill_in(F); for (size_t i = 0; i < SZ; ++i) {
EXPECT_TRUE(!control_words[i].is_default() && control_words[i] == false);
}
// test assignment for (size_t i = 0; i < SZ; ++i) {
control_words[i] = true;
EXPECT_TRUE(!control_words[i].is_default() && control_words[i] == true);
}
for (size_t i = 0; i < SZ; ++i) {
control_words[i] = false;
EXPECT_TRUE(!control_words[i].is_default() && control_words[i] == false);
}
for (size_t i = 0; i < SZ; ++i) { if ((i%2) == 0) {
control_words[i] = TriBool(true);
} else {
control_words[i] = TriBool(false);
}
}
// test copy constructor(default)
copy = control_words; for (size_t i = 0; i < SZ; ++i) { if ((i%2) == 0) {
EXPECT_TRUE(!copy[i].is_default() && copy[i] == true)
<< "even value must be true.";
} else {
EXPECT_TRUE(!copy[i].is_default() && copy[i] == false)
<< "odd value must be false.";
}
}
// test const operator[](fastpath) const TriBoolArray<SZ, T>& cref = control_words; for (size_t i = 0; i < SZ; ++i) { if ((i%2) == 0) {
EXPECT_TRUE(!cref[i].is_default() && cref[i] == true)
<< "even value must be true.";
} else {
EXPECT_TRUE(!cref[i].is_default() && cref[i] == false)
<< "odd value must be false.";
}
}
// because doit probably can't allocate jumbo arrays on stack, use static members static TriBoolArray<SZ, T> control_words; static TriBoolArray<SZ, T> copy;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.