https://github.com/killerasus/gocalc
The purpose of this Calculator is to practice unit testing in Go
https://github.com/killerasus/gocalc
codecov github-actions go golang tdd unit-testing
Last synced: about 2 months ago
JSON representation
The purpose of this Calculator is to practice unit testing in Go
- Host: GitHub
- URL: https://github.com/killerasus/gocalc
- Owner: killerasus
- License: mit
- Created: 2021-12-24T07:59:01.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-13T01:26:24.000Z (about 2 years ago)
- Last Synced: 2025-03-02T12:38:08.327Z (over 1 year ago)
- Topics: codecov, github-actions, go, golang, tdd, unit-testing
- Language: Go
- Homepage:
- Size: 99.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go RPN Calculator
An over-engineered RPN calculator built to practice unit testing, error reporting, GUI development, and CLI in Go.
[](https://app.travis-ci.com/github/killerasus/GoCalc)
## CLI
To run the command line interface of the Go RPN Calculator, go to folder `cli` and run `go run cli.go` or `go build`.
CLI interface supports flags. See implemented flags and usage with `-h` or `-help`.
For example: CLI supports expression evaluation. The result is stacked.

## GUI
### Fyne
A GUI version of the calculator made with the free and open source [fyne](https://fyne.io/) toolkit.

Compile with `go build -o gorpn.exe gui/fyne/main.go`. Remember that you will have to provide a GNU C++ compiler (in Windows you can use [MSYS2](https://www.msys2.org/) to provide GCC).
Calculator icons created by [Freepik - Flaticon](https://www.flaticon.com/free-icons/calculator).
## Testing
Run tests with `go test ./stack ./calculator ./operations -v` command in the root directory.
## Class Diagram
```mermaid
classDiagram
IStack <|-- Stack
Calculator *-- Stack
Calculator --> Operations
class IStack {
<>
+Push(float64)
+Pop() float64
+Peek() float64
+Peeki(int i) (float64, bool)
+Size() int
+IsEmpty() bool
}
class Stack {
-float64[]
}
class Calculator {
-Stack stack
+Size() int
+Push(float64 a) void
+Peek() (float64, bool)
+Peeki(i int) (float64, bool)
+Pop() (float64, bool)
+Add() (float64, bool)
+Subtract() (float64, bool)
+Multiplication() (float64, bool)
+Division() (float64, bool)
+Evaluate(string e) (v float64, ok bool)
}
class Operations {
<>
+Add(float64 a, float64 b) float64
+Subtract(float64 a, float64 b) float64
+Multiply(float64 a, float64 b) float64
+Divide(float64 a, float64 b) float64
+UnaryNegative(float64 a) float64
+Root(float64 a, float64 root) float64
+SquareRoot(float64 a) float64
}
```