@@ -35,6 +35,37 @@ constexpr Mode mode_table[] = {Mode::Conventional, Mode::M5UnitUnified};
3535
3636} // namespace
3737
38+ TEST_F (TestFacesQWERTY, Config)
39+ {
40+ SCOPED_TRACE (ustr);
41+
42+ auto cfg = unit->config ();
43+ EXPECT_TRUE (cfg.start_periodic );
44+ EXPECT_EQ (cfg.interval , 10U );
45+ EXPECT_EQ (cfg.mode , keyboard::Mode::Conventional);
46+ EXPECT_FALSE (cfg.trigger_irq );
47+
48+ cfg.interval = 50 ;
49+ unit->config (cfg);
50+ auto cfg2 = unit->config ();
51+ EXPECT_EQ (cfg2.interval , 50U );
52+
53+ // Restore
54+ cfg.interval = 10 ;
55+ unit->config (cfg);
56+ }
57+
58+ TEST_F (TestFacesQWERTY, BitwiseInitialState)
59+ {
60+ SCOPED_TRACE (ustr);
61+ EXPECT_EQ (unit->nowBits (), 0U );
62+ EXPECT_EQ (unit->pressedBits (), 0U );
63+ EXPECT_EQ (unit->releasedBits (), 0U );
64+ EXPECT_EQ (unit->holdingBits (), 0U );
65+ EXPECT_EQ (unit->repeatingBits (), 0U );
66+ EXPECT_FALSE (unit->isPressed ());
67+ }
68+
3869TEST_F (TestFacesQWERTY, Periodic)
3970{
4071 SCOPED_TRACE (ustr);
@@ -92,7 +123,7 @@ TEST_F(TestFacesQWERTY, CharacterToKeyIndexRoundtrip)
92123 if (kidx == 0xFF ) {
93124 continue ;
94125 }
95- EXPECT_LT (kidx, UnitFacesQWERTY::NUMBER_OF_KEYS )
126+ EXPECT_LT (kidx, + UnitFacesQWERTY::NUMBER_OF_KEYS )
96127 << " toKeyIndex(0x" << std::hex << c << " ) returned out-of-range key index " << (int )kidx;
97128
98129 auto mbits = UnitFacesQWERTY::character_to_mode_bits (ch);
@@ -105,23 +136,20 @@ TEST_F(TestFacesQWERTY, CharacterToKeyIndexRoundtrip)
105136 if (ch >= ' A' && ch <= ' Z' ) {
106137 EXPECT_TRUE (mbits & 0x02 ) << " char '" << ch << " ' mode_bits=" << (int )mbits << " missing shift bit" ;
107138 }
108- if (std::strchr (" !@#$%^&*(){}[]|\\ ~`?/<>=+_-;:\" '" , ch) && !(mbits & 0x03 )) {
139+ // Sym-only: not in normal/shift AND not in fn
140+ if (std::strchr (" !@#$%^&*(){}[]|\\ ~`?/<>=+_-;:\" '" , ch) && !(mbits & 0x0B )) {
109141 EXPECT_TRUE (mbits & 0x04 ) << " char '" << ch << " ' mode_bits=" << (int )mbits << " missing sym bit" ;
110142 }
111143 }
112144
113- // Verify Fn characters (>= 0x80): roundtrip must hold
114- for ( uint8_t kidx = 0 ; kidx < UnitFacesQWERTY:: NUMBER_OF_KEYS ; ++kidx) {
115- uint8_t fn_char = kidx + 128 ;
116- auto result = unit->toKeyIndex (static_cast <char >(fn_char ));
117- if (result == 0xFF ) {
145+ // Verify Fn characters: FacesQWERTY Fn chars are NOT kidx+128,
146+ // so only check range validity for all recognized >= 0x80 chars
147+ for ( int c = 128 ; c < 256 ; ++c) {
148+ auto kidx = unit->toKeyIndex (static_cast <char >(c ));
149+ if (kidx == 0xFF ) {
118150 continue ;
119151 }
120- EXPECT_EQ (result, kidx) << " Fn char 0x" << std::hex << (int )fn_char << " mapped to key " << (int )result
121- << " instead of " << (int )kidx;
122-
123- auto mbits = UnitFacesQWERTY::character_to_mode_bits (static_cast <char >(fn_char));
124- EXPECT_EQ (mbits & 0x08 , 0x08 ) << " Fn char 0x" << std::hex << (int )fn_char << " mode_bits=" << (int )mbits
125- << " missing function bit" ;
152+ EXPECT_LT (kidx, +UnitFacesQWERTY::NUMBER_OF_KEYS )
153+ << " Fn char 0x" << std::hex << c << " mapped to out-of-range key index " << (int )kidx;
126154 }
127155}
0 commit comments