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

Set MKey as uint #34

Merged
merged 5 commits into from
Dec 8, 2021
Merged

Set MKey as uint #34

merged 5 commits into from
Dec 8, 2021

Conversation

yogeshbdeshpande
Copy link
Contributor

No description provided.

@yogeshbdeshpande yogeshbdeshpande force-pushed the mkey_issue_32_branch branch 2 times, most recently from 8da15cd to 09fcc2c Compare November 24, 2021 16:30
@yogeshbdeshpande yogeshbdeshpande changed the title [WIP] Set MKey as uint Set MKey as uint Nov 24, 2021
Copy link
Contributor

@thomas-fossati thomas-fossati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good, the testing needs to be moved from the examples to the units

comid/example_test.go Outdated Show resolved Hide resolved
comid/example_test.go Show resolved Hide resolved
comid/measurement.go Outdated Show resolved Hide resolved
comid/measurement_test.go Outdated Show resolved Hide resolved
comid/test_vars.go Outdated Show resolved Hide resolved
comid/measurement_test.go Outdated Show resolved Hide resolved
comid/measurement.go Outdated Show resolved Hide resolved
comid/measurement_test.go Outdated Show resolved Hide resolved
comid/measurement_test.go Outdated Show resolved Hide resolved
comid/measurement_test.go Outdated Show resolved Hide resolved
comid/measurement_test.go Outdated Show resolved Hide resolved
comid/measurement_test.go Outdated Show resolved Hide resolved
comid/measurement_test.go Outdated Show resolved Hide resolved
comid/example_test.go Outdated Show resolved Hide resolved
comid/measurement.go Outdated Show resolved Hide resolved
comid/measurement.go Outdated Show resolved Hide resolved
comid/measurement.go Outdated Show resolved Hide resolved
comid/measurement.go Outdated Show resolved Hide resolved
comid/measurement_test.go Outdated Show resolved Hide resolved
comid/measurement_test.go Outdated Show resolved Hide resolved
comid/measurement_test.go Outdated Show resolved Hide resolved
comid/measurement_test.go Outdated Show resolved Hide resolved
comid/test_vars.go Outdated Show resolved Hide resolved
@yogeshbdeshpande yogeshbdeshpande force-pushed the mkey_issue_32_branch branch 3 times, most recently from ea7b1c7 to c71d7d4 Compare December 2, 2021 12:59
fmt.Printf("CBOR: %x\n", actual)
}
}
func TestMkey_MarshalCBOR_uint_notok(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func TestMkey_MarshalCBOR_uint_notok(t *testing.T) {
func TestMkey_MarshalCBOR_uint_not_ok(t *testing.T) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test does not seem specific to uint mkeys

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we have one single test vector using a table is superfluous.

}
}

func TestMkey_UnmarshalCBOR_uint_notok(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect the test vectors here to be such that GetKeyUint fails rather than the failure happening on the generic mkey unmarshaler

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not clear what you are saying here!

In UnMarshal CBOR a Byte stream will be passed to the decoder. If an invalid data is passed, then

it should fail Unmarshaling.

If the Unmarshal is a success, then GetKeyUint will never fail ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway I think, I understood what you are trying to say, have corrected it now!

comid/measurement_test.go Outdated Show resolved Hide resolved
}
}

func TestMkey_MarshalJSON_uint_notok(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same set of comments as above:

  1. we have one only vector therefore we don't need a full-blown table driven test
    but most importantly:
  2. there is nothing specific to the uint mkey that is tested here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For 1. I agree, that I will perhaps add one more test so that it is justified to have a table driven logic.

}
}

func TestMkey_UnmarshalJSON_uint_notok(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect the test vectors here to be such that GetKeyUint fails rather than the failure happening on the generic mkey unmarshaler

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here, as above!

assert.EqualError(t, err, expectedErr)
}

func TestMeasurement_MarshalCBOR_uint_mkey_ok(t *testing.T) {
Copy link
Contributor Author

@yogeshbdeshpande yogeshbdeshpande Dec 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func TestMeasurement_MarshalCBOR_uint_mkey_ok(t *testing.T) {
func TestMKey_MarshalCBOR_uint_ok(t *testing.T) {

}
}

func TestMkey_UnmarshalCBOR_uint_not_ok(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test for Mkey as Valid but Not a Uint Mkey

@thomas-fossati
Copy link
Contributor

Cool. One last thing: it seems that we can increase the coverage threshold to 84.4% now!

@yogeshbdeshpande
Copy link
Contributor Author

Yes!

@thomas-fossati
Copy link
Contributor

Yes!

can you move the needle in .github/workflows/ci-go-cover.yml please?

@yogeshbdeshpande
Copy link
Contributor Author

Sure will do!

@yogeshbdeshpande
Copy link
Contributor Author

Ambit in an another PR

@thomas-fossati thomas-fossati merged commit f876630 into main Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants