Skip to content

Commit

Permalink
minimaze dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin8105 committed May 21, 2020
1 parent 4c30e1c commit 14ed525
Show file tree
Hide file tree
Showing 340 changed files with 2,114 additions and 239 deletions.
14 changes: 4 additions & 10 deletions bolt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"testing"

bolt "github.com/Konstantin8105/Eurocode3.Bolt"
"github.com/bradleyjkemp/cupaloy"
)

func TestBoltClass(t *testing.T) {
Expand Down Expand Up @@ -111,19 +110,14 @@ func boltProperty(b bolt.Bolt) (s string) {
}

func TestCases(t *testing.T) {
snapshotter := cupaloy.New(cupaloy.SnapshotSubdirectory("testdata"))
for _, bd := range bolt.GetBoltDiameterList() {
for _, bc := range bolt.GetBoltClassList() {
b := bolt.New(bd, bc)

testName := fmt.Sprintf("%s%s", bd, bc)
t.Run(testName, func(t *testing.T) {
result := boltProperty(b)
err := snapshotter.SnapshotMulti(testName, result)
if err != nil {
t.Fatalf("error: %s", err)
}
})
// create filename of test
filename := fmt.Sprintf("%s%s", bd, bc)
result := boltProperty(b)
testCase(t, filename, result)
}
}
}
42 changes: 0 additions & 42 deletions distance.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,45 +106,3 @@ func ShowAllDimensions(b Bolt, thk Dimension) (s string) {

return
}

/*
String Output()
{
String out = new String();
out = "";
out += "Bolt: " + PrintfDia(DiameterBolt) + "\n";
out += "Class of bolt: " + PrintfBS(BS) + "\n";
out += "Diameter of hole: " + DiameterHole + " mm\n";
out += "Partial safety factor for joint:\n";
out += String.format("gammaM2 = %.2f\n",gamma_M2);
out += "\n";
out += "The gross cross-section area of bolt:\n";
out += String.format("A = %.1f sq.mm\n",A );
out += "The tensile stress area of the bolt:\n";
out += String.format("As = %.1f sq.mm\n",As);
out += "\n";
out += "Nominal value of the yield strength(table 3.1 EN1993-1-8):\n";
out += String.format("Fyb = %.1f MPA\n",EN1993_1_8_TABLE_3_1_Fyb(BS) );
out += "Nominal value of the ultimate tensile strength(table 3.1 EN1993-1-8):\n";
out += String.format("Fub = %.1f MPA\n",EN1993_1_8_TABLE_3_1_Fub(BS) );
out += "\n";
out += "Shear resistance per shear plane(table 3.4 EN1993-1-8):\n";
out += String.format("Fv,Rd = %.1fkN\n",F_v_Rd*1e-3);
out += "Tension resistance(table 3.4 EN1993-1-8):\n";
out += String.format("Ft,Rd = %.1fkN\n",F_t_Rd*1e-3);
out += "\n";
out += "Minimal spacing, end and edge distances(table 3.3 EN1993-1-8):\n";
out += String.format("End distance e1 = %.1f mm\n",EN1993_1_8_TABLE_3_3_e1_min(DiameterBolt) );
out += String.format("Edge distance e2 = %.1f mm\n",EN1993_1_8_TABLE_3_3_e2_min(DiameterBolt) );
out += String.format("Distance e3 in slotted holes = %.1f mm\n",EN1993_1_8_TABLE_3_3_e3_min(DiameterBolt) );
out += String.format("Distance e4 in slotted holes = %.1f mm\n",EN1993_1_8_TABLE_3_3_e4_min(DiameterBolt) );
out += String.format("Spacing p1 = %.1f mm\n",EN1993_1_8_TABLE_3_3_p1_min(DiameterBolt) );
out += String.format("Spacing p2 = %.1f mm\n",EN1993_1_8_TABLE_3_3_p2_min(DiameterBolt) );
// *
if(B_p_Rd < 1e20)
out += "B_p_Rd = %.1f kN\n",B_p_Rd*1e-3);* //
return out;
};
};
*/
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/Konstantin8105/Eurocode3.Bolt

go 1.14
54 changes: 35 additions & 19 deletions resistance_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package bolt_test

import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
"text/tabwriter"

bolt "github.com/Konstantin8105/Eurocode3.Bolt"
"github.com/bradleyjkemp/cupaloy"
)

func ExampleShearResistance() {
Expand Down Expand Up @@ -137,20 +139,40 @@ func boltShearResistance(b bolt.Bolt) (s string) {
return
}

func testCase(t *testing.T, filename, result string) {
t.Run(filename, func(t *testing.T) {
// name of test folder
const folder string = "testdata"
filename = filepath.Join(folder, filename)

// for update test screens run in console:
// UPDATE=true go test
if os.Getenv("UPDATE") == "true" {
if err := ioutil.WriteFile(filename, []byte(result), 0644); err != nil {
t.Fatalf("Cannot write snapshot to file: %v", err)
}
}

// compare datas
content, err := ioutil.ReadFile(filename)
if err != nil {
t.Fatalf("Cannot read snapshot file: %v", err)
}
if !bytes.Equal([]byte(result), content) {
t.Errorf("Snapshots is not same:\n%s\n%s", result, string(content))
}
})
}

func TestShearResistanceCases(t *testing.T) {
snapshotter := cupaloy.New(cupaloy.SnapshotSubdirectory("testdata"))
for _, bd := range bolt.GetBoltDiameterList() {
for _, bc := range bolt.GetBoltClassList() {
b := bolt.New(bd, bc)

testName := fmt.Sprintf("ShearResistance%s%s", bd, bc)
t.Run(testName, func(t *testing.T) {
result := boltShearResistance(b)
err := snapshotter.SnapshotMulti(testName, result)
if err != nil {
t.Fatalf("error: %s", err)
}
})
filename := fmt.Sprintf("ShearResistance%s%s", bd, bc)

result := boltShearResistance(b)
testCase(t, filename, result)
}
}
}
Expand All @@ -168,19 +190,13 @@ func boltTensionResistance(b bolt.Bolt) (s string) {
}

func TestTensionResistanceCases(t *testing.T) {
snapshotter := cupaloy.New(cupaloy.SnapshotSubdirectory("testdata"))
for _, bd := range bolt.GetBoltDiameterList() {
for _, bc := range bolt.GetBoltClassList() {
b := bolt.New(bd, bc)

testName := fmt.Sprintf("TensionResistance%s%s", bd, bc)
t.Run(testName, func(t *testing.T) {
result := boltTensionResistance(b)
err := snapshotter.SnapshotMulti(testName, result)
if err != nil {
t.Fatalf("error: %s", err)
}
})
filename := fmt.Sprintf("TensionResistance%s%s", bd, bc)
result := boltTensionResistance(b)
testCase(t, filename, result)
}
}
}
Expand Down
1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM12Cl10.9

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM12Cl4.6

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM12Cl4.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM12Cl5.6

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM12Cl5.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM12Cl6.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM12Cl8.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM16Cl10.9

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM16Cl4.6

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM16Cl4.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM16Cl5.6

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM16Cl5.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM16Cl6.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM16Cl8.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM20Cl10.9

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM20Cl4.6

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM20Cl4.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM20Cl5.6

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM20Cl5.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM20Cl6.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM20Cl8.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM24Cl10.9

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM24Cl4.6

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM24Cl4.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM24Cl5.6

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM24Cl5.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM24Cl6.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM24Cl8.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM30Cl10.9

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM30Cl4.6

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM30Cl4.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM30Cl5.6

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM30Cl5.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM30Cl6.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM30Cl8.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM36Cl10.9

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM36Cl4.6

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM36Cl4.8

This file was deleted.

1 change: 0 additions & 1 deletion testdata/Eurocode3%2eBolt_test-TestCases-func1-HM36Cl5.6

This file was deleted.

Loading

0 comments on commit 14ed525

Please sign in to comment.