aboutsummaryrefslogtreecommitdiff
path: root/tests/enum_minmax
diff options
context:
space:
mode:
Diffstat (limited to 'tests/enum_minmax')
-rw-r--r--tests/enum_minmax/SConscript8
-rw-r--r--tests/enum_minmax/enumminmax.proto22
-rw-r--r--tests/enum_minmax/enumminmax_unittests.c16
3 files changed, 46 insertions, 0 deletions
diff --git a/tests/enum_minmax/SConscript b/tests/enum_minmax/SConscript
new file mode 100644
index 0000000..6a66cbd
--- /dev/null
+++ b/tests/enum_minmax/SConscript
@@ -0,0 +1,8 @@
+# Test that different sizes of enum fields are properly encoded and decoded.
+
+Import('env')
+
+env.NanopbProto('enumminmax')
+
+p = env.Program(["enumminmax_unittests.c",])
+env.RunTest(p)
diff --git a/tests/enum_minmax/enumminmax.proto b/tests/enum_minmax/enumminmax.proto
new file mode 100644
index 0000000..482a8db
--- /dev/null
+++ b/tests/enum_minmax/enumminmax.proto
@@ -0,0 +1,22 @@
+/* Test out-of-order enum values.
+ */
+
+syntax = "proto3";
+
+enum Language {
+ UNKNOWN = 0;
+ ENGLISH_EN_GB = 12;
+ ENGLISH_EN_US = 1;
+ FRENCH_FR_FR = 2;
+ ITALIAN_IT_IT = 3;
+ GERMAN_DE_DE = 4;
+ SPANISH_ES_AR = 13;
+ SPANISH_ES_ES = 5;
+ SPANISH_ES_MX = 14;
+ SWEDISH_SV_SE = 6;
+ DUTCH_NL_NL = 7;
+ KOREAN_KO_KR = 8;
+ JAPANESE_JA_JP = 9;
+ CHINESE_SIMPLIFIED_ZH_CN = 10;
+ CHINESE_TRADITIONAL_ZH_TW = 11;
+}
diff --git a/tests/enum_minmax/enumminmax_unittests.c b/tests/enum_minmax/enumminmax_unittests.c
new file mode 100644
index 0000000..ccb10a4
--- /dev/null
+++ b/tests/enum_minmax/enumminmax_unittests.c
@@ -0,0 +1,16 @@
+#include "unittests.h"
+#include "enumminmax.pb.h"
+
+int main()
+{
+ int status = 0;
+
+ COMMENT("Verify min/max on unsorted enum");
+ {
+ TEST(_Language_MIN == Language_UNKNOWN);
+ TEST(_Language_MAX == Language_SPANISH_ES_MX);
+ TEST(_Language_ARRAYSIZE == (Language_SPANISH_ES_MX+1));
+ }
+
+ return status;
+}