Revert "Device/Driver/LX: Add small delay after baud rate change"
[xcsoar.git] / test / src / TestByteOrder.inc.cpp
bloba5f2114eefc7eba977a7ebb806d824c38f5ce017
1 /* Copyright_License {
3 XCSoar Glide Computer - http://www.xcsoar.org/
4 Copyright (C) 2000-2013 The XCSoar Project
5 A detailed list of copyright holders can be found in the file "AUTHORS".
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 int
24 main(int argc, char **argv)
26 plan_tests(12);
28 uint8_t test1[] = { 0x42, 0x00 };
29 ok1(ReadUnalignedLE16((const uint16_t *)(const void *)test1) == 0x0042);
30 ok1(ReadUnalignedBE16((const uint16_t *)(const void *)test1) == 0x4200);
32 uint8_t test2[] = { 0x00, 0x42 };
33 ok1(ReadUnalignedLE16((const uint16_t *)(const void *)test2) == 0x4200);
34 ok1(ReadUnalignedBE16((const uint16_t *)(const void *)test2) == 0x0042);
36 uint8_t test3[] = { 0x37, 0x13 };
37 ok1(ReadUnalignedLE16((const uint16_t *)(const void *)test3) == 0x1337);
38 ok1(ReadUnalignedBE16((const uint16_t *)(const void *)test3) == 0x3713);
40 WriteUnalignedLE16((uint16_t *)(void *)test2, 0x0042);
41 ok1(test2[0] == 0x42 && test2[1] == 0x00);
43 WriteUnalignedLE16((uint16_t *)(void *)test3, 0x4200);
44 ok1(test3[0] == 0x00 && test3[1] == 0x42);
46 WriteUnalignedLE16((uint16_t *)(void *)test1, 0x1337);
47 ok1(test1[0] == 0x37 && test1[1] == 0x13);
49 WriteUnalignedBE16((uint16_t *)(void *)test2, 0x4200);
50 ok1(test2[0] == 0x42 && test2[1] == 0x00);
52 WriteUnalignedBE16((uint16_t *)(void *)test3, 0x0042);
53 ok1(test3[0] == 0x00 && test3[1] == 0x42);
55 WriteUnalignedBE16((uint16_t *)(void *)test1, 0x3713);
56 ok1(test1[0] == 0x37 && test1[1] == 0x13);
58 return exit_status();