@@ -27,7 +27,8 @@ public abstract class ExecutorTest
2727 new object [ ] { "0 + 1" , ( IntPtr ) 0x1 } ,
2828 new object [ ] { "0 - 1" , ( IntPtr ) ( - 1 ) } ,
2929 new object [ ] { "1 + 2 * 3" , ( IntPtr ) 0x7 } ,
30- new object [ ] { "0x123 + 0x234 * 0x345" , ( IntPtr ) 0x73527 }
30+ new object [ ] { "0x123 + 0x234 * 0x345" , ( IntPtr ) 0x73527 } ,
31+ new object [ ] { "4 / 0x2" , ( IntPtr ) 0x2 }
3132 } ;
3233
3334 [ Theory ]
@@ -61,5 +62,34 @@ public void ModuleExpressionTest(string expression, IntPtr expected)
6162
6263 Check . That ( executor . Execute ( Parser . Parse ( expression ) , mock . Object ) ) . IsEqualTo ( expected ) ;
6364 }
65+
66+ public static IEnumerable < object [ ] > GetReadMemoryExpressionTestData ( ) => new List < object [ ] >
67+ {
68+ new object [ ] { "[0]" , ( IntPtr ) 0x0 } ,
69+ new object [ ] { "[0] + 10" , ( IntPtr ) 0x10 } ,
70+ new object [ ] { "[10]" , ( IntPtr ) 0x10 } ,
71+ new object [ ] { "[10 + 10]" , ( IntPtr ) 0x20 } ,
72+ new object [ ] { "[[10] + 10]" , ( IntPtr ) 0x20 } ,
73+ new object [ ] { "[[10] + [10]] + [10]" , ( IntPtr ) 0x30 }
74+ } ;
75+
76+ [ Theory ]
77+ [ MemberData ( nameof ( GetReadMemoryExpressionTestData ) ) ]
78+ public void ReadMemoryExpressionTest ( string expression , IntPtr expected )
79+ {
80+ var mock = new Mock < IProcessReader > ( ) ;
81+ mock . Setup ( p => p . ReadRemoteInt32 ( ( IntPtr ) 0 ) )
82+ . Returns ( 0 ) ;
83+ mock . Setup ( p => p . ReadRemoteInt32 ( ( IntPtr ) 0x10 ) )
84+ . Returns ( 0x10 ) ;
85+ mock . Setup ( p => p . ReadRemoteInt32 ( ( IntPtr ) 0x20 ) )
86+ . Returns ( 0x20 ) ;
87+ mock . Setup ( p => p . ReadRemoteInt32 ( ( IntPtr ) 0x30 ) )
88+ . Returns ( 0x30 ) ;
89+
90+ var executor = CreateExecutor ( ) ;
91+
92+ Check . That ( executor . Execute ( Parser . Parse ( expression ) , mock . Object ) ) . IsEqualTo ( expected ) ;
93+ }
6494 }
6595}
0 commit comments