go-hep.org/x/hep@v0.38.1/heppdt/pdt_test.go (about)

     1  // Copyright ©2017 The go-hep Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package heppdt
     6  
     7  import (
     8  	"math"
     9  	"testing"
    10  )
    11  
    12  const epsilon = 1e-20
    13  
    14  func TestDefaultTable(t *testing.T) {
    15  	if defaultTable.Len() != 534 {
    16  		t.Fatalf("expected default table to hold [534] particles. got=%v", defaultTable.Len())
    17  	}
    18  
    19  	p := ParticleByID(1)
    20  	if p == nil {
    21  		t.Fatalf("could not retrieve info about pid=1")
    22  	}
    23  	if p.ID != 1 {
    24  		t.Fatalf("expected pid=1. got=%d", p.ID)
    25  	}
    26  	if p.Name != "d" {
    27  		t.Fatalf("expected name=d. got=%q", p.Name)
    28  	}
    29  	if p.Mass != 0.33 {
    30  		t.Fatalf("expected mass=0.33. got=%v", p.Mass)
    31  	}
    32  	if math.Abs(-1./3.-p.Charge) > epsilon {
    33  		t.Fatalf("expected e-charge=-1/3. got=%v", p.Charge)
    34  	}
    35  
    36  	p = ParticleByID(1000020040)
    37  	if p == nil {
    38  		t.Fatalf("could not retrieve info about pid=1000020040")
    39  	}
    40  	if p.ID != 1000020040 {
    41  		t.Fatalf("expected pid=1000020040. got=%d", p.ID)
    42  	}
    43  	if p.Name != "Alpha-(He4)" {
    44  		t.Fatalf("expected name=Alpha-(He4). got=%q", p.Name)
    45  	}
    46  	if p.Mass != 3.72742 {
    47  		t.Fatalf("expected mass=3.72742. got=%v", p.Mass)
    48  	}
    49  	if math.Abs(2.-p.Charge) > epsilon {
    50  		t.Fatalf("expected e-charge=2. got=%v", p.Charge)
    51  	}
    52  
    53  }
    54  
    55  func TestLocation(t *testing.T) {
    56  	if Nj != 1 {
    57  		t.Fatalf("expected Nj==1. got=%d", Nj)
    58  	}
    59  
    60  	if Nq3 != 2 {
    61  		t.Fatalf("expected Nq3==2. got=%d", Nq3)
    62  	}
    63  
    64  	if Nq2 != 3 {
    65  		t.Fatalf("expected Nq2==3. got=%d", Nq2)
    66  	}
    67  
    68  	if Nq1 != 4 {
    69  		t.Fatalf("expected Nq1==4. got=%d", Nq1)
    70  	}
    71  
    72  	if Nl != 5 {
    73  		t.Fatalf("expected Nl==5. got=%d", Nl)
    74  	}
    75  
    76  	if Nr != 6 {
    77  		t.Fatalf("expected Nr==6. got=%d", Nr)
    78  	}
    79  
    80  	if N != 7 {
    81  		t.Fatalf("expected N==7. got=%d", N)
    82  	}
    83  
    84  	if N8 != 8 {
    85  		t.Fatalf("expected N8==8. got=%d", N8)
    86  	}
    87  
    88  	if N9 != 9 {
    89  		t.Fatalf("expected N9==9. got=%d", N9)
    90  	}
    91  
    92  	if N10 != 10 {
    93  		t.Fatalf("expected N10==10. got=%d", N10)
    94  	}
    95  
    96  }