Commonwealth Fusion Systems software may perform integer calculations related to SPARC operations. Implement a function that calculates the factorial of a non-negative integer, then validate it with representative and boundary-focused test cases.
The factorial of n, written as n!, is the product of every integer from 1 through n. By definition, 0! equals 1.
Implement factorial(n), where n is an integer from 0 through 12. Return an integer containing n!. Your test coverage must include the smallest valid input, a typical input, and a larger input within the constraints.
def factorial(n):