MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / TEST_F

Function TEST_F

test/plugins/wasmedge_ffmpeg/avcodec/avCodec.cpp:16–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14namespace WasmEdgeFFmpeg {
15
16TEST_F(FFmpegTest, AVCodec) {
17 ASSERT_TRUE(AVCodecMod != nullptr);
18
19 uint32_t AVCodecPtr = UINT32_C(20);
20 uint32_t StringPtr = UINT32_C(68);
21 uint32_t NumeratorPtr = UINT32_C(72);
22 uint32_t DenominatorPtr = UINT32_C(76);
23 std::string FileName = "ffmpeg-assets/sample_video.mp4"; // 32 chars
24 spdlog::info("Init FFmpeg Structs"sv);
25 initFFmpegStructs(AVCodecPtr, UINT32_C(24), UINT32_C(28), FileName,
26 UINT32_C(60), UINT32_C(64), UINT32_C(68), UINT32_C(72));
27
28 uint32_t AVCodecId = readUInt32(MemInst, AVCodecPtr);
29 auto *FuncInst =
30 AVCodecMod->findFuncExports("wasmedge_ffmpeg_avcodec_avcodec_id");
31 EXPECT_NE(FuncInst, nullptr);
32 EXPECT_TRUE(FuncInst->isHostFunction());
33
34 auto &HostFuncAVCodecID =
35 dynamic_cast<WasmEdge::Host::WasmEdgeFFmpeg::AVcodec::AVCodecID &>(
36 FuncInst->getHostFunc());
37
38 spdlog::info("Testing AVCodecId"sv);
39 {
40 EXPECT_TRUE(HostFuncAVCodecID.run(
41 CallFrame, std::initializer_list<WasmEdge::ValVariant>{AVCodecId},
42 Result));
43 EXPECT_EQ(Result[0].get<int32_t>(), 27); // H264
44 }
45
46 FuncInst =
47 AVCodecMod->findFuncExports("wasmedge_ffmpeg_avcodec_avcodec_type");
48 EXPECT_NE(FuncInst, nullptr);
49 EXPECT_TRUE(FuncInst->isHostFunction());
50
51 auto &HostFuncAVCodecType =
52 dynamic_cast<WasmEdge::Host::WasmEdgeFFmpeg::AVcodec::AVCodecType &>(
53 FuncInst->getHostFunc());
54
55 spdlog::info("Testing AVCodecType"sv);
56 {
57 EXPECT_TRUE(HostFuncAVCodecType.run(
58 CallFrame, std::initializer_list<WasmEdge::ValVariant>{AVCodecId},
59 Result));
60 EXPECT_EQ(Result[0].get<int32_t>(),
61 0); // MediaType is Video
62 }
63
64 FuncInst =
65 AVCodecMod->findFuncExports("wasmedge_ffmpeg_avcodec_avcodec_max_lowres");
66 EXPECT_NE(FuncInst, nullptr);
67 EXPECT_TRUE(FuncInst->isHostFunction());
68
69 auto &HostFuncAVCodecMaxLowres =
70 dynamic_cast<WasmEdge::Host::WasmEdgeFFmpeg::AVcodec::AVCodecMaxLowres &>(
71 FuncInst->getHostFunc());
72
73 spdlog::info("Testing AVCodecMaxLowres"sv);

Callers

nothing calls this directly

Calls 5

readUInt32Function · 0.85
findFuncExportsMethod · 0.80
isHostFunctionMethod · 0.80
fillMemContentFunction · 0.50
runMethod · 0.45

Tested by

no test coverage detected