File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1
1
#include < gtest/gtest.h>
2
+ #include < zasm/testdata/x86/instructions.hpp>
2
3
#include < zasm/zasm.hpp>
3
4
4
5
namespace zasm ::tests
@@ -369,4 +370,23 @@ namespace zasm::tests
369
370
ASSERT_EQ (data, nullptr );
370
371
}
371
372
373
+ // Test to ensure that we stay under 4 GiB of memory with a large number of instructions.
374
+ TEST (ProgramTests, Test1MillionInstructions)
375
+ {
376
+ Program program (MachineMode::AMD64);
377
+
378
+ x86::Assembler assembler (program);
379
+
380
+ constexpr auto kMaxInstructions = 1'000'000 ;
381
+
382
+ for (size_t i = 0 ; i < kMaxInstructions ; i++)
383
+ {
384
+ const auto & instrEntry = data::Instructions[i % std::size (data::Instructions)];
385
+
386
+ ASSERT_EQ (instrEntry.emitter (assembler), ErrorCode::None) << instrEntry.instrBytes << " , " << instrEntry.operation ;
387
+ }
388
+
389
+ ASSERT_EQ (program.size (), kMaxInstructions );
390
+ }
391
+
372
392
} // namespace zasm::tests
You can’t perform that action at this time.
0 commit comments