commit d92a64893a6815229c3e0871ee079a86a07cc3dc
parent b96ac44384536715c59ca522d28cc1defc2d48f7
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 1 Mar 2017 17:44:20 +0100
Test the parsing of the thin_dielectric material
Diffstat:
3 files changed, 87 insertions(+), 14 deletions(-)
diff --git a/cmake/parser/CMakeLists.txt b/cmake/parser/CMakeLists.txt
@@ -80,6 +80,8 @@ if(NOT NO_TEST)
${SOLPARSER_SOURCE_DIR}/yaml/test_ok_3.yaml)
add_test(test_solparser_ok_4 test_solparser
${SOLPARSER_SOURCE_DIR}/yaml/test_ok_4.yaml)
+ add_test(test_solparser_ok_5 test_solparser
+ ${SOLPARSER_SOURCE_DIR}/yaml/test_ok_5.yaml)
add_test(test_solparser_ko test_solparser -e
${SOLPARSER_SOURCE_DIR}/yaml/test_ko_0.yaml)
diff --git a/src/parser/yaml/test_ko_0.yaml b/src/parser/yaml/test_ko_0.yaml
@@ -16,7 +16,7 @@
- sun: { spectrum: [{data: 1}] }
---
# missing data
-- sun: { spectrum: [{wavelength: 1}] }
+- sun: { spectrum: [{wavelength: 1}] }
---
# 2x wavelength
- sun: { spectrum: [{wavelength: 1, wavelength: 1}] }
@@ -143,7 +143,7 @@
- sun: { dni: 1, dni: 1 }
---
# 2x spectrum
-- sun:
+- sun:
spectrum: [{wavelength: 1, data: 1}]
spectrum: [{wavelength: 1, data: 1}]
---
@@ -223,6 +223,35 @@
---
#
+# <thin-dielectric> ::=
+# thin_dielectric:
+# absorption: REAL # in [0, 1]
+# thickness: REAL # in [0, INF)
+# refractive_index: REAL # in ]0, INF)
+#
+
+# invalid absorption
+- material:
+ thin_dielectric: { absorption: -1, thickness: 0, refractive_index: 1 }
+---
+# invalid absorption
+- material:
+ thin_dielectric: { absorption: 1.001, thickness: 0, refractive_index: 1 }
+---
+# invalid thickness
+- material:
+ thin_dielectric: { absorption: 0, thickness: -0.01, refractive_index: 1 }
+---
+# invalid refractive index
+- material:
+ thin_dielectric: { absorption: 0, thickness: 0, refractive_index: 0 }
+---
+# invalid refractive index
+- material:
+ thin_dielectric: { absorption: 0, thickness: 0, refractive_index: -0.0001 }
+---
+
+#
# front: <material-descriptor>
#
@@ -254,7 +283,7 @@
#
# missing material definition
-- material:
+- material:
---
# unknown dummy parameter
- material: { dummy: 123 }
@@ -865,14 +894,14 @@
# spacing: REAL # in [0, INF)
# ref_point: <real3>
# <target>
-#
+#
# <target> ::=
# target:
# anchor: <anchor-identifier>
# | direction: <real3>
# | position: <real3>
# | <sun>
-#
+#
# missing zx_pivot definition
- entity:
@@ -1081,7 +1110,7 @@
#
# <geometry-data> ::=
# primary: INTEGER # in [0, 1]
-# <geometry>
+# <geometry>
#
# missing entity definition
@@ -1197,9 +1226,9 @@
---
# 2x children
- entity:
- children:
+ children:
- name: "child1"
- children:
+ children:
- name: "child2"
---
# 2 entities with the same name
@@ -1230,7 +1259,7 @@
#
# <geometry-data> ::=
# primary: INTEGER # in [0, 1]
-# <geometry>
+# <geometry>
#
# missing template definition
@@ -1364,9 +1393,9 @@
---
# 2x children
- template: &temp
- children:
+ children:
- name: "child1"
- children:
+ children:
- name: "child2"
- entity: *temp
---
@@ -1441,7 +1470,7 @@
- geometry:
---
# unknown dummy parameter
-- geometry:
+- geometry:
- dummy: 1
---
# missing material definition
@@ -1494,4 +1523,4 @@
geometry:
- cuboid: { size: [1, 2, 3] }
material: { matte: { reflectivity: 1 } }
-
-\ No newline at end of file
+
diff --git a/src/parser/yaml/test_ok_5.yaml b/src/parser/yaml/test_ok_5.yaml
@@ -0,0 +1,43 @@
+- sun: { dni: 1, spectrum: [{wavelength: 1, data: 1}] }
+
+- material: &thin_dielectric
+ thin_dielectric:
+ absorption: 0.1
+ thickness: 0.2
+ refractive_index: 1.00027
+
+- entity:
+ name: "entity"
+ primary: 0
+ geometry:
+ - material: *thin_dielectric
+ cylinder: { height: 1, radius: 1 }
+---
+- sun: { dni: 1, spectrum: [{wavelength: 1, data: 1}] }
+
+- material: &thin_dielectric
+ thin_dielectric:
+ absorption: 0
+ thickness: 0
+ refractive_index: 0.0001
+
+- entity:
+ name: "entity"
+ primary: 0
+ geometry:
+ - material: *thin_dielectric
+ cylinder: { height: 1, radius: 1 }
+
+---
+- sun: { dni: 1, spectrum: [{wavelength: 1, data: 1}] }
+- entity:
+ name: "entity"
+ primary: 0
+ geometry:
+ - cylinder: { height: 1, radius: 1 }
+ material:
+ thin_dielectric:
+ absorption: 0
+ thickness: 10
+ refractive_index: 0.0001
+