Giter Site home page Giter Site logo

Comments (4)

icemint0828 avatar icemint0828 commented on May 30, 2024 1

Thank you for your thoughtful response!
I understand both.

I get to work.

from tcping.

icemint0828 avatar icemint0828 commented on May 30, 2024

Hi, @pouriyajamshidi.
I'd like take up this issue.

Is it okay to add the functionality to calcTime?

And, may I add the like following test?

package main

import "testing"

func Test_calcTime(t *testing.T) {
	type args struct {
		time uint
	}
	tests := []struct {
		name string
		args args
		want string
	}{
		{
			name: "1 second",
			args: args{1},
			want: "1 second",
		},
		{
			name: "59 seconds",
			args: args{59},
			want: "59 seconds",
		},
		{
			name: "1 minute",
			args: args{1 * 60},
			want: "1 minute",
		},
		{
			name: "59 minutes",
			args: args{59 * 60},
			want: "59.0 minutes.seconds",
		},
		{
			name: "1.5 minute.seconds",
			args: args{1*60 + 5},
			want: "1.5 minute.seconds",
		},
		{
			name: "2.5 minutes.seconds",
			args: args{2*60 + 5},
			want: "2.5 minutes.seconds",
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := calcTime(tt.args.time); got != tt.want {
				t.Errorf("calcTime() = %v, want %v", got, tt.want)
			}
		})
	}
}

from tcping.

pouriyajamshidi avatar pouriyajamshidi commented on May 30, 2024

Hi @icemint0828,

Thanks for reaching out. You are more than welcome to take up this ticket.

To answer your questions:

  1. The check has to indeed extend calcTime. However, it is better to have the actual logic in a separate function like calcSeconds for easier referencing and refactoring in the future.
  2. The test at the first glance looks good to me. But it is better to name it like TestCalcTime to conform to Go's styling.

If you see some other parts of the code can use test cases and improvements, please feel free to open issues for them too.

Thanks!

from tcping.

pouriyajamshidi avatar pouriyajamshidi commented on May 30, 2024

Thank you for your thoughtful response! I understand both.

I get to work.

Thanks and best of luck!

from tcping.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.