@@ -442,12 +442,18 @@ namespace shellanything { namespace test
442442 v.SetExprtk (" 5 > 1" );
443443 ASSERT_TRUE ( v.Validate (c) );
444444
445- // assert a string expression
445+ // assert a string expression with ==
446446 v.SetExprtk (" 'test'=='test'" );
447447 ASSERT_TRUE ( v.Validate (c) );
448448 v.SetExprtk (" 'foo'=='bar'" );
449449 ASSERT_FALSE ( v.Validate (c) );
450450
451+ // assert a string expression with !=
452+ v.SetExprtk (" 'test'!='test'" );
453+ ASSERT_FALSE ( v.Validate (c) );
454+ v.SetExprtk (" 'foo'!='bar'" );
455+ ASSERT_TRUE ( v.Validate (c) );
456+
451457 // assert an expression with properties
452458 pmgr.SetProperty (" foo" , " bar" );
453459 v.SetExprtk (" '${foo}'=='bar'" );
@@ -782,6 +788,63 @@ namespace shellanything { namespace test
782788 ASSERT_FALSE ( v.Validate (c) );
783789 }
784790 // --------------------------------------------------------------------------------------------------
791+ TEST_F (TestValidator, testExprtkInversed)
792+ {
793+ Context c;
794+ #ifdef _WIN32
795+ {
796+ Context::ElementList elements;
797+ elements.push_back (" C:\\ Windows\\ System32\\ kernel32.dll" );
798+ elements.push_back (" C:\\ Windows\\ System32\\ cmd.exe" );
799+ elements.push_back (" C:\\ Windows\\ System32\\ notepad.exe" );
800+ elements.push_back (" C:\\ Windows\\ System32\\ services.msc" );
801+ c.SetElements (elements);
802+ }
803+ #else
804+ // TODO: complete with known path to files
805+ #endif
806+ c.RegisterProperties ();
807+
808+ PropertyManager & pmgr = PropertyManager::GetInstance ();
809+
810+ Validator v;
811+ v.SetInserve (" exprtk" );
812+
813+ // assert default
814+ ASSERT_TRUE ( v.Validate (c) );
815+
816+ // assert an expression that resolve as true
817+ v.SetExprtk (" 5>1" );
818+ ASSERT_FALSE ( v.Validate (c) );
819+
820+ // assert an expression that resolve as false
821+ v.SetExprtk (" 5<1" );
822+ ASSERT_TRUE ( v.Validate (c) );
823+
824+ // assert expression with spaces
825+ v.SetExprtk (" 5 > 1" );
826+ ASSERT_FALSE ( v.Validate (c) );
827+
828+ // assert a string expression with ==
829+ v.SetExprtk (" 'test'=='test'" );
830+ ASSERT_FALSE ( v.Validate (c) );
831+ v.SetExprtk (" 'foo'=='bar'" );
832+ ASSERT_TRUE ( v.Validate (c) );
833+
834+ // assert a string expression with !=
835+ v.SetExprtk (" 'test'!='test'" );
836+ ASSERT_TRUE ( v.Validate (c) );
837+ v.SetExprtk (" 'foo'!='bar'" );
838+ ASSERT_FALSE ( v.Validate (c) );
839+
840+ // assert an expression with properties
841+ pmgr.SetProperty (" foo" , " bar" );
842+ v.SetExprtk (" '${foo}'=='bar'" );
843+ ASSERT_FALSE ( v.Validate (c) );
844+ v.SetExprtk (" 'bar'=='${foo}'" );
845+ ASSERT_FALSE ( v.Validate (c) );
846+ }
847+ // --------------------------------------------------------------------------------------------------
785848 TEST_F (TestValidator, testInversedAll)
786849 {
787850 Validator v;
0 commit comments