AUnit  0.5.0
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
Flash.h
Go to the documentation of this file.
1 /*
2 MIT License
3 
4 Copyright (c) 2018 Brian T. Park
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in all
14 copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 SOFTWARE.
23 */
24 
38 #ifndef AUNIT_FLASH_H
39 #define AUNIT_FLASH_H
40 
41 class __FlashStringHelper;
42 
43 #ifdef ESP8266
44  #include <pgmspace.h>
45 #else
46  #include <avr/pgmspace.h>
47 #endif
48 
49 // Defined in ESP8266, not defined in AVR or Teensy
50 #ifndef FPSTR
51  #define FPSTR(pstr_pointer) \
52  (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
53 #endif
54 
55 // These are used only in AssertionVerboseMacros.h and the "Verbose" methods of
56 // Assertion.h because ESP8266 cannot handle F() strings in both inline and
57 // non-inlnie contexts. So don't use F() strings on ESP8266.
58 #ifdef ESP8266
59  #define AUNIT_F(x) (x)
60  namespace aunit {
61  namespace internal {
62  typedef const char* FlashStringType;
63  }
64  }
65 #else
66  #define AUNIT_F(x) F(x)
67  namespace aunit {
68  namespace internal {
69  typedef const __FlashStringHelper* FlashStringType;
70  }
71  }
72 #endif
73 
74 #endif