# 2004-03-16 Halldór Guðmundsson and Morten Lange # Keyboard definition file for the Icelandic keyboard # to be used in rdesktop 1.3.x ( See rdesktop.org) # generated from XKB map de, and changed manually # Location for example /usr/local/share/rdesktop/keymaps/is include common map 0x40f exclam 0x02 shift onesuperior 0x02 altgr exclamdown 0x02 shift altgr quotedbl 0x03 shift twosuperior 0x03 altgr oneeighth 0x03 shift altgr #section 0x04 shift numbersign 0x04 shift threesuperior 0x04 altgr sterling 0x04 shift altgr dollar 0x05 shift onequarter 0x05 altgr currency 0x05 shift altgr percent 0x06 shift onehalf 0x06 altgr threeeighths 0x06 shift altgr ampersand 0x07 shift threequarters 0x07 altgr fiveeighths 0x07 shift altgr slash 0x08 shift braceleft 0x08 altgr seveneighths 0x08 shift altgr parenleft 0x09 shift bracketleft 0x09 altgr trademark 0x09 shift altgr parenright 0x0a shift bracketright 0x0a altgr plusminus 0x0a shift altgr equal 0x0b shift braceright 0x0b altgr #ssharp 0x0c odiaeresis 0x0c #question 0x0c shift Odiaeresis 0x0c shift backslash 0x0c altgr questiondown 0x0c shift altgr #acute 0x0d minus 0x0d #dead_acute 0x0d #grave 0x0d shift #dead_grave 0x0d shift underscore 0x0d shift dead_cedilla 0x0d altgr dead_ogonek 0x0d shift altgr at 0x10 altgr Greek_OMEGA 0x10 shift altgr EuroSign 0x12 altgr paragraph 0x13 altgr registered 0x13 shift altgr tslash 0x14 altgr Tslash 0x14 shift altgr #z 0x15 addupper leftarrow 0x15 altgr yen 0x15 shift altgr downarrow 0x16 altgr uparrow 0x16 shift altgr rightarrow 0x17 altgr idotless 0x17 shift altgr oslash 0x18 altgr Ooblique 0x18 shift altgr #thorn 0x19 altgr #THORN 0x19 shift altgr #udiaeresis 0x1a #Udiaeresis 0x1a shift #dead_diaeresis 0x1a altgr #dead_abovering 0x1a shift altgr eth 0x1a ETH 0x1a shift apostrophe 0x1b question 0x1b shift #plus 0x1b #asterisk 0x1b shift asciitilde 0x1b altgr #grave 0x1b altgr #dead_tilde 0x1b altgr #dead_macron 0x1b shift altgr #ae 0x1e altgr #AE 0x1e shift altgr #eth 0x20 altgr #eth 0x20 #ETH 0x20 shift altgr #ETH 0x20 shift dstroke 0x21 altgr ordfeminine 0x21 shift altgr eng 0x22 altgr ENG 0x22 shift altgr hstroke 0x23 altgr Hstroke 0x23 shift altgr kra 0x25 altgr #adiaeresis 0x27 #Adiaeresis 0x27 shift ae 0x27 AE 0x27 shift dead_doubleacute 0x27 altgr #adiaeresis 0x28 #Adiaeresis 0x28 shift #dead_caron 0x28 shift altgr #asciicircum 0x29 acute 0x28 dead_acute 0x28 #dead_circumflex 0x29 #degree 0x29 shift #notsign 0x29 altgr plus 0x2b asterisk 0x2b shift grave 0x2b altgr #numbersign 0x2b #apostrophe 0x2b shift #dead_breve 0x2b shift altgr #y 0x2c addupper guillemotleft 0x2c altgr guillemotright 0x2d altgr cent 0x2e altgr copyright 0x2e shift altgr leftdoublequotemark 0x2f altgr rightdoublequotemark 0x30 altgr mu 0x32 altgr masculine 0x32 shift altgr comma 0x33 semicolon 0x33 shift horizconnector 0x33 altgr multiply 0x33 shift altgr period 0x34 colon 0x34 shift periodcentered 0x34 altgr division 0x34 shift altgr #minus 0x35 #underscore 0x35 shift thorn 0x35 THORN 0x35 shift dead_belowdot 0x35 altgr dead_abovedot 0x35 shift altgr href='#n4'>4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
# Unit Testing
If you are new to unit testing, then you can find many good resources on internet. However most of it is scattered around in small pieces here and there, and there's also many different opinions, so I won't give any recommendations.
Instead I recommend these two books, explaining two different styles of Unit Testing in detail.
* "Test Driven Development: By Example: Kent Beck"
* "Growing Object-Oriented Software, Guided By Tests: Steve Freeman, Nat Pryce"
If you prefer videos there are Uncle Bob's [Clean Coders Videos](https://cleancoders.com/), which unfortunately cost quite a bit, especially if you want to watch many of them. But James Shore has a free [Let's Play](http://www.jamesshore.com/Blog/Lets-Play) video series.
## Google Test and Google Mock
It's possible to Unit Test your code using [Google Test](https://github.com/google/googletest). The Google Test framework also includes another component for writing testing mocks and stubs, called "Google Mock". For information how to write the actual tests, please refer to the documentation on that site.
## Use of C++
Note that Google Test and therefore any test has to be written in C++, even if the rest of the QMK codebases is written in C. This should hopefully not be a problem even if you don't know any C++, since there's quite clear documentation and examples of the required C++ features, and you can write the rest of the test code almost as you would write normal C. Note that some compiler errors which you might get can look quite scary, but just read carefully what it says, and you should be ok.
One thing to remember, is that you have to append `extern "C"` around all of your C file includes.
## Adding Tests for New or Existing Features
If you want to unit test some feature, then take a look at the existing serial_link tests, in the `quantum/serial_link/tests folder`, and follow the steps below to create a similar structure.
1. If it doesn't already exist, add a test subfolder to the folder containing the feature.
2. Create a `testlist.mk` and a `rules.mk` file in that folder.
3. Include those files from the root folder `testlist.mk`and `build_test.mk` respectively.
4. Add a new name for your testgroup to the `testlist.mk` file. Each group defined there will be a separate executable. And that's how you can support mocking out different parts. Note that it's worth adding some common prefix, just like it's done for the serial_link tests. The reason for that is that the make command allows substring filtering, so this way you can easily run a subset of the tests.
5. Define the source files and required options in the `rules.mk` file.
* `_SRC` for source files
* `_DEFS` for additional defines
* `_INC` for additional include folders
6. Write the tests in a new cpp file inside the test folder you created. That file has to be one of the files included from the `rules.mk` file.
Note how there's several different tests, each mocking out a separate part. Also note that each of them only compiles the very minimum that's needed for the tests. It's recommend that you try to do the same. For a relevant video check out [Matt Hargett "Advanced Unit Testing in C & C++](https://www.youtube.com/watch?v=Wmy6g-aVgZI)
## Running the Tests
To run all the tests in the codebase, type `make test`. You can also run test matching a substring by typing `make test:matchingsubstring` Note that the tests are always compiled with the native compiler of your platform, so they are also run like any other program on your computer.
## Debugging the Tests
If there are problems with the tests, you can find the executable in the `./build/test` folder. You should be able to run those with GDB or a similar debugger.
## Full Integration Tests
It's not yet possible to do a full integration test, where you would compile the whole firmware and define a keymap that you are going to test. However there are plans for doing that, because writing tests that way would probably be easier, at least for people that are not used to unit testing.
In that model you would emulate the input, and expect a certain output from the emulated keyboard.
# Tracing Variables
Sometimes you might wonder why a variable gets changed and where, and this can be quite tricky to track down without having a debugger. It's of course possible to manually add print statements to track it, but you can also enable the variable trace feature. This works for both for variables that are changed by the code, and when the variable is changed by some memory corruption.
To take the feature into use add `VARIABLE_TRACE=x` to the end of you make command. `x` represents the number of variables you want to trace, which is usually 1.
Then at a suitable place in the code, call `ADD_TRACED_VARIABLE`, to begin the tracing. For example to trace all the layer changes, you can do this
```c
void matrix_init_user(void) {
ADD_TRACED_VARIABLE("layer", &layer_state, sizeof(layer_state));
}
```
This will add a traced variable named "layer" (the name is just for your information), which tracks the memory location of `layer_state`. It tracks 4 bytes (the size of `layer_state`), so any modification to the variable will be reported. By default you can not specify a size bigger than 4, but you can change it by adding `MAX_VARIABLE_TRACE_SIZE=x` to the end of the make command line.
In order to actually detect changes to the variables you should call `VERIFY_TRACED_VARIABLES` around the code that you think that modifies the variable. If a variable is modified it will tell you between which two `VERIFY_TRACED_VARIABLES` calls the modification happened. You can then add more calls to track it down further. I don't recommend spamming the codebase with calls. It's better to start with a few, and then keep adding them in a binary search fashion. You can also delete the ones you don't need, as each call need to store the file name and line number in the ROM, so you can run out of memory if you add too many calls.
Also remember to delete all the tracing code once you have found the bug, as you wouldn't want to create a pull request with tracing code.