On Sunday, 13 June 2021 at 16:09:48 UTC+1 kee...@gmail.com wrote: 

> For my heap, I never had to Push or Pop, I only had to initialize the heap 
> and repeatedly "Fix" the top element of the heap.  As it turns out the Init 
> and Fix functions only use the 3 sorting methods of the heap.  They don't 
> use Push or Pop. So when I ran test coverage, I found that my Push and Pop 
> implementations weren't covered.  I can't leave my Push and Pop 
> implementation out because the Init and Fix methods require heaps with all 
> 5 methods.  What do I do?


Add some unit tests (in your own application) that call heap.Push or 
heap.Pop on your heap type. That will give you the test coverage.

If you don't like carrying dead code, then you could replace your Push and 
Pop with panic() - but you'll still want unit tests that test that they 
panic, for your coverage report.

You could argue that heap.Init and heap.Fix could take a sort.Interface 
rather than a heap.Interface.  However that exposes internals, and it would 
limit backwards-compatible versions of those functions.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c8cc2631-33c2-40c0-a54e-9ebab1ee8d7fn%40googlegroups.com.

Reply via email to