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

Function TEST_F

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

Source from the content-addressed store, hash-verified

14namespace WasmEdgeFFmpeg {
15
16TEST_F(FFmpegTest, AVCodecCtx) {
17 ASSERT_TRUE(AVCodecMod != nullptr);
18
19 uint32_t AVCodecCtxPtr = UINT32_C(64);
20
21 std::string FileName = "ffmpeg-assets/sample_video.mp4"; // 32 chars
22 initFFmpegStructs(UINT32_C(20), UINT32_C(24), UINT32_C(28), FileName,
23 UINT32_C(60), AVCodecCtxPtr, UINT32_C(68), UINT32_C(72));
24 uint32_t NumPtr = UINT32_C(76);
25 uint32_t DenPtr = UINT32_C(80);
26 uint32_t AVCodecPtr = UINT32_C(84);
27
28 uint32_t AVCodecCtxId = readUInt32(MemInst, AVCodecCtxPtr);
29
30 auto *FuncInst = AVCodecMod->findFuncExports(
31 "wasmedge_ffmpeg_avcodec_avcodeccontext_codec_id");
32 EXPECT_NE(FuncInst, nullptr);
33 EXPECT_TRUE(FuncInst->isHostFunction());
34
35 auto &HostFuncAVCodecCtxCodecID = dynamic_cast<
36 WasmEdge::Host::WasmEdgeFFmpeg::AVcodec::AVCodecCtxCodecID &>(
37 FuncInst->getHostFunc());
38
39 {
40 EXPECT_TRUE(HostFuncAVCodecCtxCodecID.run(
41 CallFrame, std::initializer_list<WasmEdge::ValVariant>{AVCodecCtxId},
42 Result));
43 EXPECT_EQ(Result[0].get<uint32_t>(), 27); // H264
44 }
45
46 int32_t CodecType = 0; // MediaType Video
47 FuncInst = AVCodecMod->findFuncExports(
48 "wasmedge_ffmpeg_avcodec_avcodeccontext_set_codec_type");
49 EXPECT_NE(FuncInst, nullptr);
50 EXPECT_TRUE(FuncInst->isHostFunction());
51
52 auto &HostFuncAVCodecCtxSetCodecType = dynamic_cast<
53 WasmEdge::Host::WasmEdgeFFmpeg::AVcodec::AVCodecCtxSetCodecType &>(
54 FuncInst->getHostFunc());
55
56 {
57 EXPECT_TRUE(HostFuncAVCodecCtxSetCodecType.run(
58 CallFrame,
59 std::initializer_list<WasmEdge::ValVariant>{AVCodecCtxId, CodecType},
60 Result));
61 EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success));
62 }
63
64 FuncInst = AVCodecMod->findFuncExports(
65 "wasmedge_ffmpeg_avcodec_avcodeccontext_codec_type");
66 EXPECT_NE(FuncInst, nullptr);
67 EXPECT_TRUE(FuncInst->isHostFunction());
68
69 auto &HostFuncAVCodecCtxCodecType = dynamic_cast<
70 WasmEdge::Host::WasmEdgeFFmpeg::AVcodec::AVCodecCtxCodecType &>(
71 FuncInst->getHostFunc());
72
73 {

Callers

nothing calls this directly

Calls 5

readUInt32Function · 0.85
readSInt32Function · 0.85
findFuncExportsMethod · 0.80
isHostFunctionMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected