Этот коммит содержится в:
Softonik 2024-06-29 01:38:43 +03:00
родитель e7ec5361e8
коммит 3567ec9416
4 изменённых файлов: 0 добавлений и 154 удалений

Просмотреть файл

@ -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
}

Просмотреть файл

@ -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))
}

Просмотреть файл

@ -1,9 +0,0 @@
# language: ru
Функциональность: Точность
Сценарий: Округление температуры до десятых
То RoundTemp возвращает округлённое
Сценарий: Округление расстояний до сотых
То RoundDist возвращает округлённое

Просмотреть файл

@ -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)
}