• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ CORRADE_COMPARE_AS函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中CORRADE_COMPARE_AS函数的典型用法代码示例。如果您正苦于以下问题:C++ CORRADE_COMPARE_AS函数的具体用法?C++ CORRADE_COMPARE_AS怎么用?C++ CORRADE_COMPARE_AS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了CORRADE_COMPARE_AS函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Gerharddc,项目名称:corrade,代码行数:32,代码来源:ConfigurationTest.cpp


示例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());
}
开发者ID:BeiLuoShiMen,项目名称:magnum,代码行数:26,代码来源:QuaternionTest.cpp


示例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);
}
开发者ID:NextGenIntelligence,项目名称:corrade,代码行数:31,代码来源:StringTest.cpp


示例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);
}
开发者ID:Squareys,项目名称:magnum-plugins,代码行数:34,代码来源:DdsImporterTest.cpp


示例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);
}
开发者ID:MiUishadow,项目名称:corrade,代码行数:9,代码来源:ResourceStaticTest.cpp


示例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));
}
开发者ID:JanDupal,项目名称:magnum,代码行数:10,代码来源:DualComplexTest.cpp


示例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);
}
开发者ID:jkhoogland,项目名称:corrade,代码行数:13,代码来源:DirectoryTest.cpp


示例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);
}
开发者ID:Ali-Wassouf,项目名称:magnum,代码行数:14,代码来源:ComplexTest.cpp


示例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
}
开发者ID:piaoger,项目名称:corrade,代码行数:50,代码来源:Test.cpp


示例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);
}
开发者ID:NextGenIntelligence,项目名称:magnum,代码行数:49,代码来源:CylinderTest.cpp


示例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
}
开发者ID:jkhoogland,项目名称:magnum,代码行数:28,代码来源:BufferImageGLTest.cpp


示例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);
}
开发者ID:severin-lemaignan,项目名称:magnum,代码行数:31,代码来源:RectangleTextureGLTest.cpp


示例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);
}
开发者ID:severin-lemaignan,项目名称:magnum-plugins,代码行数:34,代码来源:MagnumFontConverterTest.cpp


示例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);
}
开发者ID:piaoger,项目名称:corrade,代码行数:16,代码来源:Test.cpp


示例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);
}

}}}
开发者ID:Ali-Wassouf,项目名称:magnum,代码行数:35,代码来源:AbstractImageConverterTest.cpp


示例16: CORRADE_VERIFY

void JpegImporterTest::rgb() {
    JpegImporter importer;
    CORRADE_VERIFY(importer.openFile(Utility::Directory::join(JPEGIMPORTER_TEST_DIR, "rgb.jpg")));

    std::optional<Trade::ImageData2D> image = importer.image2D(0);
    CORRADE_VERIFY(image);
    CORRADE_COMPARE(image->size(), Vector2i(3, 2));
    CORRADE_COMPARE(image->format(), PixelFormat::RGB);
    CORRADE_COMPARE(image->type(), PixelType::UnsignedByte);

    /* The image has four-byte aligned rows, clear the padding to deterministic
       values */
    CORRADE_COMPARE(image->data().size(), 24);
    image->data()[9] = image->data()[10] = image->data()[11] =
         image->data()[21] = image->data()[22] = image->data()[23] = 0;

    /* Data should be similar to the PNG */
    CORRADE_COMPARE_AS(image->data(), Containers::Array<char>::from(
        '\xca', '\xfe', '\x76',
        '\xdf', '\xad', '\xb6',
        '\xca', '\xfe', '\x76', 0, 0, 0,

        '\xe0', '\xad', '\xb6',
        '\xc9', '\xff', '\x76',
        '\xdf', '\xad', '\xb6', 0, 0, 0),
        TestSuite::Compare::Container<Containers::ArrayView<const char>>);
}
开发者ID:caomw,项目名称:magnum-plugins,代码行数:27,代码来源:JpegImporterTest.cpp


示例17: CORRADE_VERIFY

void WavImporterTest::mono16() {
    WavImporter importer;
    CORRADE_VERIFY(importer.openFile(Utility::Directory::join(WAVAUDIOIMPORTER_TEST_DIR, "mono16.wav")));

    CORRADE_COMPARE(importer.format(), Buffer::Format::Mono16);
    CORRADE_COMPARE(importer.frequency(), 44000);
    CORRADE_COMPARE_AS(importer.data(),
        Containers::Array<char>::from('\x1d', '\x10', '\x71', '\xc5'),
        TestSuite::Compare::Container);
}
开发者ID:matheboy,项目名称:magnum,代码行数:10,代码来源:WavImporterTest.cpp


示例18: CORRADE_COMPARE_AS

void CapsuleTest::wireframe2D() {
    Trade::MeshData2D capsule = Capsule2D::wireframe(2, 4, 0.5f);

    CORRADE_COMPARE_AS(capsule.positions(0), (std::vector<Vector2>{
        {0.0f, -1.5f},

        {-0.707107f, -1.20711f},
        {0.707107f, -1.20711f},

        {-1.0f, -0.5f},
        {1.0f, -0.5f},

        {-1.0f, -0.25f},
        {1.0f, -0.25f},

        {-1.0f, 0.0f},
        {1.0f, 0.0f},

        {-1.0f, 0.25f},
        {1.0f, 0.25f},

        {-1.0f, 0.5f},
        {1.0f, 0.5f},

        {-0.707107f, 1.20711f},
        {0.707107f, 1.20711f},

        {0.0f, 1.5f}
    }), TestSuite::Compare::Container);

    CORRADE_COMPARE_AS(capsule.indices(), (std::vector<UnsignedInt>{
        0, 1, 0, 2,

        1, 3, 2, 4,
        3, 5, 4, 6,
        5, 7, 6, 8,
        7, 9, 8, 10,
        9, 11, 10, 12,
        11, 13, 12, 14,

        13, 15, 14, 15
    }), TestSuite::Compare::Container);
}
开发者ID:NextGenIntelligence,项目名称:magnum,代码行数:43,代码来源:CapsuleTest.cpp


示例19: CORRADE_COMPARE

void DualComplexTest::rotation() {
    DualComplex a = DualComplex::rotation(Deg(120.0f));
    CORRADE_COMPARE(a.length(), 1.0f);
    CORRADE_COMPARE(a, DualComplex({-0.5f, 0.8660254f}, {0.0f, 0.0f}));
    CORRADE_COMPARE_AS(a.rotation().angle(), Deg(120.0f), Rad);

    /* Constexpr access to rotation */
    constexpr DualComplex b({-1.0f, 2.0f}, {});
    constexpr Complex c = b.rotation();
    CORRADE_COMPARE(c, Complex(-1.0f, 2.0f));
}
开发者ID:JanDupal,项目名称:magnum,代码行数:11,代码来源:DualComplexTest.cpp


示例20: CORRADE_COMPARE_AS

void UVSphereTest::withTextureCoords() {
    Trade::MeshData3D sphere = UVSphere::solid(3, 3, UVSphere::TextureCoords::Generate);

    CORRADE_COMPARE_AS(*sphere.positions(0), (std::vector<Vector3>{
        {0.0f, -1.0f, 0.0f},

        {0.0f, -0.5f, 0.866025f},
        {0.75f, -0.5f, -0.433013f},
        {-0.75f, -0.5f, -0.433013f},
        {0.0f, -0.5f, 0.866025f},

        {0.0f, 0.5f, 0.866025f},
        {0.75f, 0.5f, -0.433013f},
        {-0.75f, 0.5f, -0.433013f},
        {0.0f, 0.5f, 0.866025f},

        {0.0f, 1.0f, 0.0f}
    }), TestSuite::Compare::Container);

    CORRADE_COMPARE_AS(*sphere.textureCoords2D(0), (std::vector<Vector2>{
        {0.5f, 0.0f},

        {0.0f, 0.333333f},
        {0.333333f, 0.333333f},
        {0.666667f, 0.333333f},
        {1.0f, 0.333333f},

        {0.0f, 0.666667f},
        {0.333333f, 0.666667f},
        {0.666667f, 0.666667f},
        {1.0f, 0.666667f},

        {0.5f, 1.0f}
    }), TestSuite::Compare::Container);

    CORRADE_COMPARE_AS(*sphere.indices(), (std::vector<UnsignedInt>{
        0, 2, 1, 0, 3, 2, 0, 4, 3,
        1, 2, 6, 1, 6, 5, 2, 3, 7, 2, 7, 6, 3, 4, 8, 3, 8, 7,
        5, 6, 9, 6, 7, 9, 7, 8, 9
    }), TestSuite::Compare::Container);
}
开发者ID:respu,项目名称:magnum,代码行数:41,代码来源:UVSphereTest.cpp



注:本文中的CORRADE_COMPARE_AS函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CORRADE_INTERNAL_ASSERT函数代码示例发布时间:2022-05-30
下一篇:
C++ CORRADE_ASSERT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap