@@ -31,10 +31,11 @@ const (
31
31
testDataPath = "../../test"
32
32
csDemosPath = testDataPath + "/cs-demos"
33
33
demSetPath = csDemosPath + "/set"
34
+ demSetPathS2 = csDemosPath + "/s2"
34
35
defaultDemPath = csDemosPath + "/default.dem"
35
36
retakeDemPath = csDemosPath + "/retake_unknwon_bombsite_index.dem"
36
37
unexpectedEndOfDemoPath = csDemosPath + "/unexpected_end_of_demo.dem"
37
- s2DemPath = csDemosPath + "/s2.dem"
38
+ s2DemPath = demSetPathS2 + "/s2.dem"
38
39
)
39
40
40
41
var concurrentDemos = flag .Int ("concurrentdemos" , 2 , "The `number` of current demos" )
@@ -217,10 +218,6 @@ func TestS2(t *testing.T) {
217
218
_ , err = p .ParseHeader ()
218
219
assertions .NoError (err , "error returned by Parser.ParseHeader()" )
219
220
220
- p .RegisterEventHandler (func (e any ) {
221
- fmt .Printf ("%#v\n " , e )
222
- })
223
-
224
221
t .Log ("Parsing to end" )
225
222
err = p .ParseToEnd ()
226
223
assertions .NoError (err , "error occurred in ParseToEnd()" )
@@ -488,26 +485,20 @@ func runConcurrently(runner func()) {
488
485
wg .Wait ()
489
486
}
490
487
491
- func TestDemoSet (t * testing.T ) {
492
- t .Parallel ()
493
-
494
- if testing .Short () {
495
- t .Skip ("skipping test due to -short flag" )
496
- }
497
-
498
- dems , err := ioutil .ReadDir (demSetPath )
499
- assert .NoError (t , err , "failed to list directory %q" , demSetPath )
488
+ func testDemoSet (t * testing.T , path string ) {
489
+ dems , err := os .ReadDir (path )
490
+ assert .NoError (t , err , "failed to list directory %q" , path )
500
491
501
492
for _ , d := range dems {
502
493
name := d .Name ()
503
494
if strings .HasSuffix (name , ".dem" ) {
504
- t .Logf ("Parsing '%s/%s'\n " , demSetPath , name )
495
+ t .Logf ("Parsing '%s/%s'\n " , path , name )
505
496
func () {
506
- f := openFile (t , fmt .Sprintf ("%s/%s" , demSetPath , name ))
497
+ f := openFile (t , fmt .Sprintf ("%s/%s" , path , name ))
507
498
defer mustClose (t , f )
508
499
509
500
defer func () {
510
- assert .Nil (t , recover (), "parsing of '%s/%s' panicked" , demSetPath , name )
501
+ assert .Nil (t , recover (), "parsing of '%s/%s' panicked" , path , name )
511
502
}()
512
503
513
504
p := demoinfocs .NewParser (f )
@@ -538,12 +529,32 @@ func TestDemoSet(t *testing.T) {
538
529
})
539
530
540
531
err = p .ParseToEnd ()
541
- assert .Nil (t , err , "parsing of '%s/%s' failed" , demSetPath , name )
532
+ assert .NoError (t , err , "parsing of '%s/%s' failed" , demSetPath , name )
542
533
}()
543
534
}
544
535
}
545
536
}
546
537
538
+ func TestDemoSet (t * testing.T ) {
539
+ if testing .Short () {
540
+ t .Skip ("skipping test due to -short flag" )
541
+ }
542
+
543
+ t .Parallel ()
544
+
545
+ testDemoSet (t , demSetPath )
546
+ }
547
+
548
+ func TestDemoSetS2 (t * testing.T ) {
549
+ if testing .Short () {
550
+ t .Skip ("skipping test due to -short flag" )
551
+ }
552
+
553
+ t .Parallel ()
554
+
555
+ testDemoSet (t , demSetPathS2 )
556
+ }
557
+
547
558
func BenchmarkDemoInfoCs (b * testing.B ) {
548
559
for i := 0 ; i < b .N ; i ++ {
549
560
parseDefaultDemo (b )
0 commit comments