Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : add basic unit test to the project #6

Merged
merged 8 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ permissions:
jobs:
# Test golangci-lint for go-version define in go.mod
golangci:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Install harfbuzz
run: sudo apt-get install libharfbuzz-dev
- name: Set PKG_CONFIG_PATH
run: export PKG_CONFIG_PATH=/usr/include/harfbuzz
- name: Install GCC
run: sudo apt-get install gcc
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe #v4.1.0
with:
Expand All @@ -25,3 +31,20 @@ jobs:
with:
version: latest
only-new-issues: true

tests:
runs-on: ubuntu-24.04
steps:
- name: Install harfbuzz
run: sudo apt-get install libharfbuzz-dev
- name: Set PKG_CONFIG_PATH
run: export PKG_CONFIG_PATH=/usr/include/harfbuzz
- name: Install GCC
run: sudo apt-get install gcc
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe #v4.1.0
with:
go-version-file: go.mod
cache: false
- name: Test
run: go test -v ./...
28 changes: 28 additions & 0 deletions font_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package writer

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestFontSize(t *testing.T) {
face := &Face{} // Mock Face object
size := int32(12)

font := NewFont(face, size)
fontSize := font.Size()

assert.Equal(t, size, fontSize)
}

func TestSetFontReSize(t *testing.T) {
face := &Face{} // Mock Face object
size := int32(12)

font := NewFont(face, size)
newSize := int32(16)
font.SetSize(newSize)

assert.Equal(t, newSize, font.Size())
}
9 changes: 8 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
module github.com/haashemi/writer

go 1.20.0
go 1.20

require (
github.com/haashemi/go-harfbuzz v0.0.0-20240304202021-7d8c8e99547f
github.com/mattn/go-pointer v0.0.1
github.com/stretchr/testify v1.9.0
golang.org/x/image v0.15.0
golang.org/x/text v0.14.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

// replace github.com/haashemi/go-harfbuzz v0.0.1 => ../go-harfbuzz
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/haashemi/go-harfbuzz v0.0.0-20240304202021-7d8c8e99547f h1:3RpC5xQxtwaqG8D417EIiC23/RxOrk7g2efIz4DXZww=
github.com/haashemi/go-harfbuzz v0.0.0-20240304202021-7d8c8e99547f/go.mod h1:x/7sZksqZHTio7OmfVgHo2K1GelkqAWcg4FAIBp4iqA=
github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0=
github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=
golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading