From 3567ec94165a43cb2c0024b7e26b2cf1db30e6ea Mon Sep 17 00:00:00 2001 From: Softonik Date: Sat, 29 Jun 2024 01:38:43 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A7=D0=B8=D1=81=D1=82=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/accuracy/accuracy.go | 30 ---------------- pkg/accuracy/accuracy_test.go | 60 ------------------------------- pkg/accuracy/features/app.feature | 9 ----- pkg/accuracy/init_test.go | 55 ---------------------------- 4 files changed, 154 deletions(-) delete mode 100644 pkg/accuracy/accuracy.go delete mode 100644 pkg/accuracy/accuracy_test.go delete mode 100644 pkg/accuracy/features/app.feature delete mode 100644 pkg/accuracy/init_test.go diff --git a/pkg/accuracy/accuracy.go b/pkg/accuracy/accuracy.go deleted file mode 100644 index f351d07..0000000 --- a/pkg/accuracy/accuracy.go +++ /dev/null @@ -1,30 +0,0 @@ -package accuracy - -import ( - "math" -) - -const ( - roundingTimeHoursDigitsCount = 1 - roundingTimeHoursТочнееDigitsCount = 5 -) - -func RoundTimeHours(number float64) float64 { - return RoundFloat(number, roundingTimeHoursDigitsCount) -} -func RoundTimeHoursТочнее(number float64) float64 { - return RoundFloat(number, roundingTimeHoursТочнееDigitsCount) -} -func RoundFloat(number float64, roundingTempDigitsCount int) float64 { - temp := math.Pow(10, float64(roundingTempDigitsCount)) - return math.Round(number*temp) / temp -} - -func СекундыВМинуты(seconds int) int { - s_ostatok := seconds % 60 - res := seconds / 60 - if s_ostatok < 30 { - return res - } - return res + 1 -} diff --git a/pkg/accuracy/accuracy_test.go b/pkg/accuracy/accuracy_test.go deleted file mode 100644 index 2578484..0000000 --- a/pkg/accuracy/accuracy_test.go +++ /dev/null @@ -1,60 +0,0 @@ -package accuracy - -import ( - . "github.com/onsi/gomega" -) - -type testData struct { -} - -var ( - t *testData -) - -func resetTestData() { - t = &testData{} - _ = Ω -} - -func beforeSuite() { -} -func afterSuite() { -} - -func beforeScenario() { - resetTestData() -} -func afterScenario() { -} - -// ----------------------- -func roundTempВозвращаетОкруглённое() { - // res := RoundTemp(0.0000003) - // Ω(res).To(testlib.Be(0.0)) - - // res = RoundTemp(0.000003) - // Ω(res).To(testlib.Be(0.0)) - - // res = RoundTemp(0.003) - // Ω(res).To(testlib.Be(0.0)) - - // res = RoundTemp(0.199) - // Ω(res).To(testlib.Be(0.2)) - - // res = RoundTemp(0.3333) - // Ω(res).To(testlib.Be(0.3)) -} - -func roundDistВозвращаетОкруглённое() { - // res := RoundDist(0.0000003) - // Ω(res).To(testlib.Be(0.0)) - - // res = RoundDist(0.003) - // Ω(res).To(testlib.Be(0.0)) - - // res = RoundDist(0.03) - // Ω(res).To(testlib.Be(0.03)) - - // res = RoundDist(0.333) - // Ω(res).To(testlib.Be(0.33)) -} diff --git a/pkg/accuracy/features/app.feature b/pkg/accuracy/features/app.feature deleted file mode 100644 index 283aff6..0000000 --- a/pkg/accuracy/features/app.feature +++ /dev/null @@ -1,9 +0,0 @@ -# language: ru - -Функциональность: Точность - - Сценарий: Округление температуры до десятых - То RoundTemp возвращает округлённое - - Сценарий: Округление расстояний до сотых - То RoundDist возвращает округлённое diff --git a/pkg/accuracy/init_test.go b/pkg/accuracy/init_test.go deleted file mode 100644 index e7e0f14..0000000 --- a/pkg/accuracy/init_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package accuracy - -import ( - "context" - "os" - "testing" - - "my/schet/pkg/testlib" - - "github.com/cucumber/godog" - "github.com/cucumber/godog/colors" - - . "github.com/onsi/gomega" - gomega_format "github.com/onsi/gomega/format" -) - -func InitializeScenario(ctx *godog.ScenarioContext) { - ctx.Step(`^RoundTemp возвращает округлённое$`, roundTempВозвращаетОкруглённое) - ctx.Step(`^RoundDist возвращает округлённое$`, roundDistВозвращаетОкруглённое) - - // ----------------------- - ctx.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) { - beforeScenario() - return ctx, nil - }) - ctx.After(func(ctx context.Context, sc *godog.Scenario, err error) (context.Context, error) { - afterScenario() - return ctx, nil - }) - testlib.InitializeGomegaForGodog(ctx) - gomega_format.CharactersAroundMismatchToInclude = 50 - _ = Ω -} - -func InitializeSuite(tsc *godog.TestSuiteContext) { - tsc.BeforeSuite(beforeSuite) - tsc.AfterSuite(afterSuite) -} - -func TestMain(m *testing.M) { - var opts = godog.Options{ - Output: colors.Colored(os.Stdout), - Strict: true, - StopOnFailure: true, - } - - godog.BindCommandLineFlags("godog.", &opts) - r := godog.TestSuite{ - Name: "app", - TestSuiteInitializer: InitializeSuite, - ScenarioInitializer: InitializeScenario, - Options: &opts, - }.Run() - os.Exit(r) -}