本文整理汇总了C++中CORRADE_COMPARE_AS函数的典型用法代码示例。如果您正苦于以下问题:C++ CORRADE_COMPARE_AS函数的具体用法?C++ CORRADE_COMPARE_AS怎么用?C++ CORRADE_COMPARE_AS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CORRADE_COMPARE_AS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: conf
void ConfigurationTest::parseHierarchic() {
Configuration conf(Directory::join(CONFIGURATION_TEST_DIR, "hierarchic.conf"));
conf.setFilename(Directory::join(CONFIGURATION_WRITE_TEST_DIR, "hierarchic.conf"));
CORRADE_VERIFY(conf.isValid());
/* Check parsing */
CORRADE_VERIFY(conf.hasGroup("z"));
CORRADE_COMPARE(conf.group("z")->group("x")->group("c")->group("v")->value("key1"), "val1");
CORRADE_COMPARE(conf.groupCount("a"), 2);
CORRADE_COMPARE(conf.group("a")->groupCount("b"), 2);
CORRADE_COMPARE(conf.group("a")->group("b", 0)->value("key2"), "val2");
CORRADE_COMPARE(conf.group("a")->group("b", 1)->value("key2"), "val3");
CORRADE_COMPARE(conf.group("a", 1)->value("key3"), "val4");
CORRADE_COMPARE(conf.group("a", 1)->group("b")->value("key2"), "val5");
/* Expect no change */
CORRADE_VERIFY(conf.save());
CORRADE_COMPARE_AS(Directory::join(CONFIGURATION_WRITE_TEST_DIR, "hierarchic.conf"),
Directory::join(CONFIGURATION_TEST_DIR, "hierarchic.conf"),
TestSuite::Compare::File);
/* Modify */
conf.group("z")->group("x")->clear();
conf.group("a", 1)->addGroup("b")->setValue("key2", "val6");
conf.addGroup("q")->addGroup("w")->addGroup("e")->addGroup("r")->setValue("key4", "val7");
/* Verify changes */
CORRADE_VERIFY(conf.save());
CORRADE_COMPARE_AS(Directory::join(CONFIGURATION_WRITE_TEST_DIR, "hierarchic.conf"),
Directory::join(CONFIGURATION_TEST_DIR, "hierarchic-modified.conf"),
TestSuite::Compare::File);
}
示例2: axis
void QuaternionTest::rotation() {
std::ostringstream o;
Error::setOutput(&o);
Vector3 axis(1.0f/Constants<Float>::sqrt3());
CORRADE_COMPARE(Quaternion::rotation(Deg(-74.0f), {-1.0f, 2.0f, 2.0f}), Quaternion());
CORRADE_COMPARE(o.str(), "Math::Quaternion::rotation(): axis must be normalized\n");
Quaternion q = Quaternion::rotation(Deg(120.0f), axis);
CORRADE_COMPARE(q.length(), 1.0f);
CORRADE_COMPARE(q, Quaternion(Vector3(0.5f, 0.5f, 0.5f), 0.5f));
CORRADE_COMPARE_AS(q.angle(), Deg(120.0f), Deg);
CORRADE_COMPARE(q.axis(), axis);
CORRADE_COMPARE(q.axis().length(), 1.0f);
/* Verify negative angle */
Quaternion q2 = Quaternion::rotation(Deg(-120.0f), axis);
CORRADE_COMPARE(q2, Quaternion(Vector3(-0.5f, -0.5f, -0.5f), 0.5f));
CORRADE_COMPARE_AS(q2.angle(), Deg(120.0f), Deg);
CORRADE_COMPARE(q2.axis(), -axis);
/* Default-constructed quaternion has zero angle and NaN axis */
CORRADE_COMPARE_AS(Quaternion().angle(), Deg(0.0f), Deg);
CORRADE_VERIFY(Quaternion().axis() != Quaternion().axis());
}
示例3: CORRADE_COMPARE_AS
void StringTest::split() {
/* Empty */
CORRADE_COMPARE_AS(String::split({}, '/'),
std::vector<std::string>{}, TestSuite::Compare::Container);
CORRADE_COMPARE_AS(String::splitWithoutEmptyParts({}, '/'),
std::vector<std::string>{}, TestSuite::Compare::Container);
/* Only delimiter */
CORRADE_COMPARE_AS(String::split("/", '/'),
(std::vector<std::string>{"", ""}), TestSuite::Compare::Container);
CORRADE_COMPARE_AS(String::splitWithoutEmptyParts("/", '/'),
std::vector<std::string>{}, TestSuite::Compare::Container);
/* No delimiters */
CORRADE_COMPARE_AS(String::split("abcdef", '/'),
std::vector<std::string>{"abcdef"}, TestSuite::Compare::Container);
CORRADE_COMPARE_AS(String::splitWithoutEmptyParts("abcdef", '/'),
std::vector<std::string>{"abcdef"}, TestSuite::Compare::Container);
/* Common case */
CORRADE_COMPARE_AS(String::split("ab/c/def", '/'),
(std::vector<std::string>{"ab", "c", "def"}), TestSuite::Compare::Container);
CORRADE_COMPARE_AS(String::splitWithoutEmptyParts("ab/c/def", '/'),
(std::vector<std::string>{"ab", "c", "def"}), TestSuite::Compare::Container);
/* Empty parts */
CORRADE_COMPARE_AS(String::split("ab//c/def//", '/'),
(std::vector<std::string>{"ab", "", "c", "def", "", ""}), TestSuite::Compare::Container);
CORRADE_COMPARE_AS(String::splitWithoutEmptyParts("ab//c/def//", '/'),
(std::vector<std::string>{"ab", "c", "def"}), TestSuite::Compare::Container);
}
示例4: CORRADE_VERIFY
void DdsImporterTest::rgbWithMips() {
DdsImporter importer;
CORRADE_VERIFY(importer.openFile(Utility::Directory::join(DDSIMPORTER_TEST_DIR, "rgb_uncompressed_mips.dds")));
const char pixels[] = {'\xde', '\xad', '\xb5',
'\xca', '\xfe', '\x77',
'\xde', '\xad', '\xb5',
'\xca', '\xfe', '\x77',
'\xde', '\xad', '\xb5',
'\xca', '\xfe', '\x77'};
const char mipPixels[] = {'\xd4', '\xd5', '\x96'};
/* check image */
std::optional<Trade::ImageData2D> image = importer.image2D(0);
CORRADE_VERIFY(image);
CORRADE_VERIFY(!image->isCompressed());
CORRADE_COMPARE(image->storage().alignment(), 1);
CORRADE_COMPARE(image->size(), Vector2i(3, 2));
CORRADE_COMPARE(image->format(), PixelFormat::RGB);
CORRADE_COMPARE(image->type(), PixelType::UnsignedByte);
CORRADE_COMPARE_AS(image->data(), Containers::ArrayView<const char>(pixels),
TestSuite::Compare::Container);
/* check mip 0 */
std::optional<Trade::ImageData2D> mip = importer.image2D(1);
CORRADE_VERIFY(mip);
CORRADE_VERIFY(!mip->isCompressed());
CORRADE_COMPARE(image->storage().alignment(), 1);
CORRADE_COMPARE(mip->size(), Vector2i{1});
CORRADE_COMPARE(mip->format(), PixelFormat::RGB);
CORRADE_COMPARE(mip->type(), PixelType::UnsignedByte);
CORRADE_COMPARE_AS(mip->data(), Containers::ArrayView<const char>(mipPixels),
TestSuite::Compare::Container);
}
示例5: r
void ResourceStaticTest::get() {
Resource r("test");
CORRADE_COMPARE_AS(r.get("predisposition.bin"),
Directory::join(RESOURCE_TEST_DIR, "predisposition.bin"),
TestSuite::Compare::StringToFile);
CORRADE_COMPARE_AS(r.get("consequence.bin"),
Directory::join(RESOURCE_TEST_DIR, "consequence.bin"),
TestSuite::Compare::StringToFile);
}
示例6: Vector2
void DualComplexTest::combinedTransformParts() {
Vector2 translation = Vector2(-1.5f, 2.75f);
DualComplex a = DualComplex::translation(translation)*DualComplex::rotation(Deg(23.0f));
DualComplex b = DualComplex::rotation(Deg(23.0f))*DualComplex::translation(translation);
CORRADE_COMPARE_AS(a.rotation().angle(), Deg(23.0f), Rad);
CORRADE_COMPARE_AS(b.rotation().angle(), Deg(23.0f), Rad);
CORRADE_COMPARE(a.translation(), translation);
CORRADE_COMPARE(b.translation(), Complex::rotation(Deg(23.0f)).transformVector(translation));
}
示例7: CORRADE_VERIFY
void DirectoryTest::write() {
constexpr unsigned char data[] = {0xCA, 0xFE, 0xBA, 0xBE, 0x0D, 0x0A, 0x00, 0xDE, 0xAD, 0xBE, 0xEF};
CORRADE_VERIFY(Directory::write(Directory::join(DIRECTORY_WRITE_TEST_DIR, "file"), data));
CORRADE_COMPARE_AS(Directory::join(DIRECTORY_WRITE_TEST_DIR, "file"),
Directory::join(DIRECTORY_TEST_DIR, "file"),
TestSuite::Compare::File);
CORRADE_VERIFY(Directory::writeString(Directory::join(DIRECTORY_WRITE_TEST_DIR, "file"),
std::string("\xCA\xFE\xBA\xBE\x0D\x0A\x00\xDE\xAD\xBE\xEF", 11)));
CORRADE_COMPARE_AS(Directory::join(DIRECTORY_WRITE_TEST_DIR, "file"),
Directory::join(DIRECTORY_TEST_DIR, "file"),
TestSuite::Compare::File);
}
示例8: CORRADE_COMPARE
void ComplexTest::rotation() {
Complex a = Complex::rotation(Deg(120.0f));
CORRADE_COMPARE(a.length(), 1.0f);
CORRADE_COMPARE(a, Complex(-0.5f, 0.8660254f));
CORRADE_COMPARE_AS(a.angle(), Deg(120.0f), Rad);
/* Verify negative angle */
Complex b = Complex::rotation(Deg(-240.0f));
CORRADE_COMPARE(b, Complex(-0.5f, 0.8660254f));
CORRADE_COMPARE_AS(b.angle(), Deg(120.0f), Rad);
/* Default-constructed complex number has zero angle */
CORRADE_COMPARE_AS(Complex().angle(), Deg(0.0f), Rad);
}
示例9: defined
void Test::reloadPluginDirectory() {
#if defined(CORRADE_TARGET_NACL_NEWLIB) || defined(CORRADE_TARGET_EMSCRIPTEN)
CORRADE_SKIP("Plugin directory is irrelevant for static plugins");
#else
PluginManager::Manager<AbstractAnimal> manager(PLUGINS_DIR);
/* Load Dog and rename the plugin */
CORRADE_COMPARE(manager.load("Dog"), LoadState::Loaded);
Directory::move(Directory::join(PLUGINS_DIR, std::string("Dog") + PLUGIN_FILENAME_SUFFIX),
Directory::join(PLUGINS_DIR, std::string("LostDog") + PLUGIN_FILENAME_SUFFIX));
Directory::move(Directory::join(PLUGINS_DIR, "Dog.conf"),
Directory::join(PLUGINS_DIR, "LostDog.conf"));
/* Rename Chihuahua */
Directory::move(Directory::join(PLUGINS_DIR, std::string("Chihuahua") + PLUGIN_FILENAME_SUFFIX),
Directory::join(PLUGINS_DIR, std::string("LostChihuahua") + PLUGIN_FILENAME_SUFFIX));
Directory::move(Directory::join(PLUGINS_DIR, "Chihuahua.conf"),
Directory::join(PLUGINS_DIR, "LostChihuahua.conf"));
/* Reload plugin dir and check new name list */
manager.reloadPluginDirectory();
std::vector<std::string> actual1 = manager.pluginList();
/* Unload Dog and it should disappear from the list */
CORRADE_COMPARE(manager.unload("Dog"), LoadState::NotLoaded);
manager.reloadPluginDirectory();
std::vector<std::string> actual2 = manager.pluginList();
/** @todo Also test that "WrongMetadataFile" plugins are reloaded */
/* Rename everything back and clean up */
Directory::move(Directory::join(PLUGINS_DIR, std::string("LostDog") + PLUGIN_FILENAME_SUFFIX),
Directory::join(PLUGINS_DIR, std::string("Dog") + PLUGIN_FILENAME_SUFFIX));
Directory::move(Directory::join(PLUGINS_DIR, "LostDog.conf"),
Directory::join(PLUGINS_DIR, "Dog.conf"));
Directory::move(Directory::join(PLUGINS_DIR, std::string("LostChihuahua") + PLUGIN_FILENAME_SUFFIX),
Directory::join(PLUGINS_DIR, std::string("Chihuahua") + PLUGIN_FILENAME_SUFFIX));
Directory::move(Directory::join(PLUGINS_DIR, "LostChihuahua.conf"),
Directory::join(PLUGINS_DIR, "Chihuahua.conf"));
manager.reloadPluginDirectory();
/* And now we can safely compare */
CORRADE_COMPARE_AS(actual1, (std::vector<std::string>{
"Canary", "Dog", "LostChihuahua", "LostDog", "Snail"}), TestSuite::Compare::Container);
CORRADE_COMPARE_AS(actual2, (std::vector<std::string>{
"Canary", "LostChihuahua", "LostDog", "Snail"}), TestSuite::Compare::Container);
#endif
}
示例10: CORRADE_COMPARE_AS
void CylinderTest::wireframe() {
Trade::MeshData3D cylinder = Cylinder::wireframe(2, 8, 0.5f);
CORRADE_COMPARE_AS(cylinder.positions(0), (std::vector<Vector3>{
{0.0f, -0.5f, 1.0f},
{1.0f, -0.5f, 0.0f},
{0.0f, -0.5f, -1.0f},
{-1.0f, -0.5f, 0.0f},
{0.707107f, -0.5f, 0.707107f},
{0.707107f, -0.5f, -0.707107f},
{-0.707107f, -0.5f, -0.707107f},
{-0.707107f, -0.5f, 0.707107f},
{0.0f, 0.0f, 1.0f},
{1.0f, 0.0f, 0.0f},
{0.0f, 0.0f, -1.0f},
{-1.0f, 0.0f, 0.0f},
{0.707107f, 0.0f, 0.707107f},
{0.707107f, 0.0f, -0.707107f},
{-0.707107f, 0.0f, -0.707107f},
{-0.707107f, 0.0f, 0.707107f},
{0.0f, 0.5f, 1.0f},
{1.0f, 0.5f, 0.0f},
{0.0f, 0.5f, -1.0f},
{-1.0f, 0.5f, 0.0f},
{0.707107f, 0.5f, 0.707107f},
{0.707107f, 0.5f, -0.707107f},
{-0.707107f, 0.5f, -0.707107f},
{-0.707107f, 0.5f, 0.707107f}
}), TestSuite::Compare::Container);
CORRADE_COMPARE(cylinder.normalArrayCount(), 0);
CORRADE_COMPARE_AS(cylinder.indices(), (std::vector<UnsignedInt>{
0, 4, 1, 5, 2, 6, 3, 7,
4, 1, 5, 2, 6, 3, 7, 0,
0, 8, 1, 9, 2, 10, 3, 11,
8, 12, 9, 13, 10, 14, 11, 15,
12, 9, 13, 10, 14, 11, 15, 8,
8, 16, 9, 17, 10, 18, 11, 19,
16, 20, 17, 21, 18, 22, 19, 23,
20, 17, 21, 18, 22, 19, 23, 16
}), TestSuite::Compare::Container);
}
示例11: MAGNUM_VERIFY_NO_ERROR
void BufferImageGLTest::constructCompressed() {
const char data[] = { 'a', 0, 0, 0, 'b', 0, 0, 0 };
CompressedBufferImage2D a{
#ifndef MAGNUM_TARGET_GLES
CompressedPixelStorage{}.setCompressedBlockSize(Vector3i{4}),
#endif
CompressedPixelFormat::RGBAS3tcDxt1,
{4, 4}, data, BufferUsage::StaticDraw};
#ifndef MAGNUM_TARGET_GLES
const auto imageData = a.buffer().data();
#endif
MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(a.storage().compressedBlockSize(), Vector3i{4});
#endif
CORRADE_COMPARE(a.format(), CompressedPixelFormat::RGBAS3tcDxt1);
CORRADE_COMPARE(a.size(), Vector2i(4, 4));
CORRADE_COMPARE(a.dataSize(), 8);
/** @todo How to verify the contents in ES? */
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE_AS(imageData, Containers::ArrayView<const char>{data},
TestSuite::Compare::Container);
#endif
}
示例12: CORRADE_SKIP
void TextureGLTest::subImageBuffer() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
constexpr UnsignedByte zero[4*4*4] = {};
constexpr UnsignedByte subData[] = { 0x00, 0x01, 0x02, 0x03,
0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b,
0x0c, 0x0d, 0x0e, 0x0f };
RectangleTexture texture;
texture.setImage(TextureFormat::RGBA8,
ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), zero));
texture.setSubImage(Vector2i(1),
BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), subData, BufferUsage::StaticDraw));
MAGNUM_VERIFY_NO_ERROR();
BufferImage2D image(ColorFormat::RGBA, ColorType::UnsignedByte);
texture.image(image, BufferUsage::StaticRead);
const auto imageData = image.buffer().data<UnsignedByte>();
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(image.size(), Vector2i(4));
CORRADE_COMPARE_AS(std::vector<UnsignedByte>(imageData.begin(), imageData.end()), (std::vector<UnsignedByte>{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0,
0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}), TestSuite::Compare::Container);
}
示例13: CORRADE_VERIFY
void MagnumFontConverterTest::exportFont() {
/* Remove previously created files */
Utility::Directory::rm(Utility::Directory::join(MAGNUMFONTCONVERTER_TEST_WRITE_DIR, "font.conf"));
Utility::Directory::rm(Utility::Directory::join(MAGNUMFONTCONVERTER_TEST_WRITE_DIR, "font.tga"));
/* Open font */
FreeTypeFont font;
CORRADE_VERIFY(font.openFile(Utility::Directory::join(FREETYPEFONT_TEST_DIR, "Oxygen.ttf"), 16.0f));
/* Create fake cache */
MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::texture_rg);
GlyphCache cache(TextureFormat::R8, Vector2i(1536), Vector2i(256), Vector2i(24));
cache.insert(font.glyphId(U'W'), {25, 34}, {{0, 8}, {16, 128}});
cache.insert(font.glyphId(U'e'), {25, 12}, {{16, 4}, {64, 32}});
/* Convert the file */
MagnumFontConverter converter;
converter.exportFontToFile(font, cache, Utility::Directory::join(MAGNUMFONTCONVERTER_TEST_WRITE_DIR, "font"), "Wave");
/* Verify font parameters */
/** @todo This might behave differently elsewhere due to unspecified order of glyphs in cache */
CORRADE_COMPARE_AS(Utility::Directory::join(MAGNUMFONTCONVERTER_TEST_WRITE_DIR, "font.conf"),
Utility::Directory::join(MAGNUMFONT_TEST_DIR, "font.conf"),
TestSuite::Compare::File);
/* Verify font image, no need to test image contents, as the image is garbage anyway */
Trade::TgaImporter importer;
CORRADE_VERIFY(importer.openFile(Utility::Directory::join(MAGNUMFONTCONVERTER_TEST_WRITE_DIR, "font.tga")));
std::optional<Trade::ImageData2D> image = importer.image2D(0);
CORRADE_VERIFY(image);
CORRADE_COMPARE(image->size(), Vector2i(256));
CORRADE_COMPARE(image->format(), ImageFormat::Red);
CORRADE_COMPARE(image->type(), ImageType::UnsignedByte);
}
示例14: manager
void Test::nameList() {
#if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_EMSCRIPTEN)
{
PluginManager::Manager<AbstractAnimal> manager(PLUGINS_DIR);
CORRADE_COMPARE_AS(manager.pluginList(), (std::vector<std::string>{
"Canary", "Chihuahua", "Dog", "Snail"}), TestSuite::Compare::Container);
}
#endif
/* Check if the list of dynamic plugins is cleared after destructing */
PluginManager::Manager<AbstractAnimal> manager(Directory::join(PLUGINS_DIR, "nonexistent"));
CORRADE_COMPARE_AS(manager.pluginList(), std::vector<std::string>{
"Canary"}, TestSuite::Compare::Container);
}
示例15: AbstractImageConverterTest
namespace Magnum { namespace Trade { namespace Test {
class AbstractImageConverterTest: public TestSuite::Tester {
public:
explicit AbstractImageConverterTest();
void exportToFile();
};
AbstractImageConverterTest::AbstractImageConverterTest() {
addTests({&AbstractImageConverterTest::exportToFile});
}
void AbstractImageConverterTest::exportToFile() {
class DataExporter: public Trade::AbstractImageConverter {
private:
Features doFeatures() const override { return Feature::ConvertData; }
Containers::Array<char> doExportToData(const ImageView2D& image) override {
return Containers::Array<char>::from(char(image.size().x()), char(image.size().y()));
};
};
/* Remove previous file */
Utility::Directory::rm(Utility::Directory::join(TRADE_TEST_OUTPUT_DIR, "image.out"));
/* doExportToFile() should call doExportToData() */
DataExporter exporter;
ImageView2D image(PixelFormat::RGBA, PixelType::UnsignedByte, {0xfe, 0xed}, {nullptr, 0xfe*0xed*4});
CORRADE_VERIFY(exporter.exportToFile(image, Utility::Directory::join(TRADE_TEST_OUTPUT_DIR, "image.out")));
CORRADE_COMPARE_AS(Utility::Directory::join(TRADE_TEST_OUTPUT_DIR, "image.out"),
"\xFE\xED", TestSuite::Compare::FileToString);
}
}}}