2019-09-23 09:05:19 +01:00
|
|
|
/*
|
|
|
|
Pominal
|
2020-02-11 16:27:47 +00:00
|
|
|
Copyright (C) 2020 Daniel Anglin
|
2019-09-23 09:05:19 +01:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
2020-01-20 09:13:47 +00:00
|
|
|
var newPominalTestCases = []struct {
|
2020-01-18 01:04:51 +00:00
|
|
|
name string
|
2019-09-23 09:05:19 +01:00
|
|
|
description string
|
|
|
|
workSession float64
|
|
|
|
shortBreakSession float64
|
|
|
|
longBreakSession float64
|
|
|
|
maxWorkSessions int
|
|
|
|
expectedPominal Pominal
|
|
|
|
}{
|
|
|
|
{
|
2020-01-18 01:04:51 +00:00
|
|
|
name: "Test case 1",
|
|
|
|
description: "When creating a Pominal value with all valid parameters.",
|
2019-09-23 09:05:19 +01:00
|
|
|
workSession: 1200,
|
|
|
|
shortBreakSession: 300,
|
|
|
|
longBreakSession: 600,
|
|
|
|
maxWorkSessions: 5,
|
|
|
|
expectedPominal: Pominal{
|
|
|
|
workSession: 1,
|
|
|
|
maxWorkSessions: 5,
|
|
|
|
cycle: 1,
|
|
|
|
countdown: 0,
|
|
|
|
work: 1200,
|
|
|
|
shortBreak: 300,
|
|
|
|
longBreak: 600,
|
|
|
|
label: "",
|
2020-01-19 21:26:46 +00:00
|
|
|
stopChan: nil,
|
2019-09-23 09:05:19 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-01-18 01:04:51 +00:00
|
|
|
name: "Test case 2",
|
|
|
|
description: "When creating a Pominal value where the work session is set below the minimum allowed time.",
|
2019-09-23 09:05:19 +01:00
|
|
|
workSession: 59.9999999999999999999999999999999,
|
|
|
|
shortBreakSession: 1536,
|
|
|
|
longBreakSession: 1200,
|
|
|
|
maxWorkSessions: 4,
|
|
|
|
expectedPominal: Pominal{
|
|
|
|
workSession: 1,
|
|
|
|
maxWorkSessions: 4,
|
|
|
|
cycle: 1,
|
|
|
|
countdown: 0,
|
|
|
|
work: 60,
|
|
|
|
shortBreak: 1536,
|
|
|
|
longBreak: 1200,
|
|
|
|
label: "",
|
2020-01-19 21:26:46 +00:00
|
|
|
stopChan: nil,
|
2019-09-23 09:05:19 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-01-18 01:04:51 +00:00
|
|
|
name: "Test case 3",
|
|
|
|
description: "When creating a Pominal value where both short break and long break sessions are set below the minimum allowed time.",
|
2019-09-23 09:05:19 +01:00
|
|
|
workSession: 1000,
|
|
|
|
shortBreakSession: 1.23,
|
|
|
|
longBreakSession: 45.6743,
|
|
|
|
maxWorkSessions: 1,
|
|
|
|
expectedPominal: Pominal{
|
|
|
|
workSession: 1,
|
|
|
|
maxWorkSessions: 1,
|
|
|
|
cycle: 1,
|
|
|
|
countdown: 0,
|
|
|
|
work: 1000,
|
|
|
|
shortBreak: 60,
|
|
|
|
longBreak: 60,
|
|
|
|
label: "",
|
2020-01-19 21:26:46 +00:00
|
|
|
stopChan: nil,
|
2019-09-23 09:05:19 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-01-18 01:04:51 +00:00
|
|
|
name: "Test case 4",
|
|
|
|
description: "When creatng a Pominal where the maximum work sessions set below 1.",
|
2019-09-23 09:05:19 +01:00
|
|
|
workSession: 1500,
|
|
|
|
shortBreakSession: 300,
|
|
|
|
longBreakSession: 1200,
|
|
|
|
maxWorkSessions: -1,
|
|
|
|
expectedPominal: Pominal{
|
|
|
|
workSession: 1,
|
|
|
|
maxWorkSessions: 1,
|
|
|
|
cycle: 1,
|
|
|
|
countdown: 0,
|
|
|
|
work: 1500,
|
|
|
|
shortBreak: 300,
|
|
|
|
longBreak: 1200,
|
|
|
|
label: "",
|
2020-01-19 21:26:46 +00:00
|
|
|
stopChan: nil,
|
2019-09-23 09:05:19 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2020-01-20 09:13:47 +00:00
|
|
|
|
|
|
|
var sessionsTestCases = []struct {
|
|
|
|
name string
|
|
|
|
description string
|
|
|
|
expectedWorkSession int
|
|
|
|
expectedCycle int
|
|
|
|
expectedLabel string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "Test session 1",
|
|
|
|
description: "When the first work session has started.",
|
|
|
|
expectedWorkSession: 1,
|
|
|
|
expectedCycle: 1,
|
|
|
|
expectedLabel: workTimerLabel,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Test session 2",
|
|
|
|
description: "When the first work session has finished and the short break session has started.",
|
|
|
|
expectedWorkSession: 1,
|
|
|
|
expectedCycle: 1,
|
|
|
|
expectedLabel: shortBreakTimerLabel,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Test session 3",
|
|
|
|
description: "When the short break session has finished and the second work session has started.",
|
|
|
|
expectedWorkSession: 2,
|
|
|
|
expectedCycle: 1,
|
|
|
|
expectedLabel: workTimerLabel,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Test session 4",
|
2020-01-24 09:51:21 +00:00
|
|
|
description: "When the second work session has finished and the long break has started.",
|
2020-01-20 09:13:47 +00:00
|
|
|
expectedWorkSession: 2,
|
|
|
|
expectedCycle: 1,
|
|
|
|
expectedLabel: longBreakTimerLabel,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Test session 5",
|
|
|
|
description: "When the long break session has finished and the new work session has started for the next Pominal cycle.",
|
|
|
|
expectedWorkSession: 1,
|
|
|
|
expectedCycle: 2,
|
|
|
|
expectedLabel: workTimerLabel,
|
|
|
|
},
|
|
|
|
}
|