@@ -40,34 +40,55 @@ func conformanceHelper(doc conformance.ReferenceStore, cluster matter.Cluster, c
4040 return raymond .SafeString (b .String ())
4141}
4242
43+ func renderChoice (c * conformance.Optional , b * strings.Builder ) {
44+ // PICS tool does not support + style conformances, so unless this is a "pick one" choice,
45+ //render as fully optional, we'll check the choice conformance properly in the tests.
46+ o := conformance.ChoiceExactLimit {Limit : 1 }
47+ if c .Choice != nil && o .Equal (c .Choice .Limit ) {
48+ b .WriteRune ('.' )
49+ b .WriteString (c .Choice .ASCIIDocString ())
50+ }
51+ }
52+
4353func renderConformance (cs conformance.Set , b * strings.Builder , doc conformance.ReferenceStore , cluster * matter.Cluster , formatter conformanceEntityFormatter ) {
44- for _ , c := range cs {
45- switch c := c .(type ) {
46- case * conformance.Mandatory :
47- if c .Expression == nil {
48- b .WriteString ("M" )
49- continue
50- }
51- renderExpression (b , doc , cluster , c .Expression , formatter )
52- case * conformance.Optional :
53- if c .Expression == nil {
54- b .WriteString ("O" )
55- if c .Choice != nil {
56- b .WriteRune ('.' )
57- b .WriteString (c .Choice .ASCIIDocString ())
58- }
59- continue
60- }
61- b .WriteRune ('[' )
62- renderExpression (b , doc , cluster , c .Expression , formatter )
63- b .WriteRune (']' )
64- if c .Choice != nil {
65- b .WriteRune ('.' )
66- b .WriteString (c .Choice .ASCIIDocString ())
67- }
54+ // PICS tool can't handle otherwise conformances, so render anything with an otherwise conformance as optional for the purposes of the
55+ // test plan PICS. This can be fully evaluated in the tests.
56+ // The only exception is if it is provisional, which should be rendered as X.
57+ if len (cs ) != 1 {
58+ switch cs [0 ].(type ) {
59+ case * conformance.Provisional :
60+ b .WriteRune ('X' )
6861 default :
69- b .WriteString (fmt .Sprintf ("unknown conformance: %T" , c ))
62+ b .WriteString ("{PICS_S}: O" )
63+ }
64+ return
65+ }
66+ switch c := cs [0 ].(type ) {
67+ case * conformance.Mandatory :
68+ if c .Expression == nil {
69+ b .WriteString ("{PICS_S}: M" )
70+ return
7071 }
72+ renderExpression (b , doc , cluster , c .Expression , formatter )
73+ case * conformance.Optional :
74+ if c .Expression == nil {
75+ b .WriteString ("{PICS_S}: O" )
76+ renderChoice (c , b )
77+ return
78+ }
79+ renderExpression (b , doc , cluster , c .Expression , formatter )
80+ b .WriteString (": O" )
81+ renderChoice (c , b )
82+ case * conformance.Provisional :
83+ b .WriteRune ('X' )
84+ case * conformance.Disallowed :
85+ b .WriteRune ('X' )
86+ case * conformance.Deprecated :
87+ b .WriteRune ('X' )
88+ case * conformance.Described :
89+ b .WriteString ("{PICS_S}: O" )
90+ default :
91+ b .WriteString (fmt .Sprintf ("unknown conformance: %T" , c ))
7192 }
7293}
7394
@@ -87,7 +108,7 @@ func renderExpression(b *strings.Builder, doc conformance.ReferenceStore, cluste
87108 b .WriteString (renderReference (doc , exp .Reference , formatter ))
88109 case * conformance.LogicalExpression :
89110 if exp .Not {
90- b .WriteRune ( '!' )
111+ b .WriteString ( "NOT" )
91112 }
92113 b .WriteRune ('(' )
93114 renderExpression (b , doc , cluster , exp .Left , formatter )
0 commit comments