0032144: Draw Harness - add -silent option to command Close
[occt.git] / tests / bugs / step / bug30694
CommitLineData
e3249d8e 1puts "================"
2puts "0030694: Data Exchange - support non-standard GB2312-encoded STEP files"
3puts ""
4puts "Test case:"
5puts "1) Creates a temporary STEP file-template using WriteStep."
6puts "2) Reads generated template and replaces @tmp_name@ entity in it with Simplified Chinese characters using Tcl."
7puts "3) Generates 2 STEP files in UTF-8 and GB2312 encodings (converted by Tcl)."
8puts "4) Reads generated files using StepRead and validates entity name."
9puts "================"
10puts ""
11
12proc fileToString { thePath } {
13 set aFile [open "$thePath" r]
14 set aText [read $aFile [file size "$thePath"]]
15 close $aFile
16 return $aText
17}
18
19proc fileFromString { thePath theContent theCodePage } {
20 set aFile [open "$thePath" w]
21 fconfigure $aFile -translation lf -encoding "$theCodePage"
22 puts $aFile $theContent
23 close $aFile
24}
25
26pload XDE OCAF MODELING VISUALIZATION
27set aTmpNameTmpl "@tmp_name@"
28set aTmpFileTmpl "${imagedir}/${casename}-tmp.stp"
29set aTmpFileUtf8 "${imagedir}/${casename}-tmp-utf8.stp"
30set aTmpFileGb "${imagedir}/${casename}-tmp-gb.stp"
31# 国标
32set aName [encoding convertfrom unicode "\xFD\x56\x07\x68"]
33box b 1 2 3
395d00e0 34Close A T U G -silent
e3249d8e 35XNewDoc T
36XAddShape T b 0
37XSetColor T b 1 0 0
38SetName T 0:1:1:1 "$aTmpNameTmpl"
39GetName T 0:1:1:1
40WriteStep T "$aTmpFileTmpl"
41
42regsub -all -- $aTmpNameTmpl [fileToString "$aTmpFileTmpl"] "$aName" aContent
43fileFromString "$aTmpFileUtf8" "$aContent" "utf-8"
44fileFromString "$aTmpFileGb" "$aContent" "gb2312"
45
1b9cb073 46param read.step.codepage UTF8
e3249d8e 47ReadStep U "$aTmpFileUtf8"
48ReadStep A "$aTmpFileGb"
1b9cb073 49param read.step.codepage GB
e3249d8e 50ReadStep G "$aTmpFileGb"
51
52if { [GetName U 0:1:1:1] != "$aName" } { puts "Error: unable to read UTF-8 STEP" }
53if { [GetName G 0:1:1:1] != "$aName" } { puts "Error: unable to read gb2312 STEP" }
54if { [GetName A 0:1:1:1] == "$aName" } { puts "Error: broken test case" }