# Path: canvas/lib/uint8clampedarray.py
# class Uint8ClampedArray(array):
#     def __new__(cls, size=0):
#         return array.__new__(cls, 'B', [0] * size)
# 
#     def __getitem__(self, key):
#         return array.__getitem__(self, key)
# 
#     def __setitem__(self, key, value):
#         if value < 0:
#             value = 0
#         elif value > 255:
#             value = 255
#         return array.__setitem__(self, key, value)


import unittest
from canvas.lib.uint8clampedarray import Uint8ClampedArray
"""Tests for Canvas.CanvasRenderingContext2D.Uint8ClampedArray"""


class Uint8ClampedArrayTest(unittest.TestCase):
    """Tests for Uint8ClampedArray"""

    def setUp(self):
        self.clampedArray = Uint8ClampedArray(3)
        self.clampedArray[0] = -17 # Should get clamped at 0
        self.clampedArray[1] = 93  # Should remain at 93
        self.clampedArray[2] = 350 # Should get clamped at 255

    def test_is_instance(self):

# Path: canvas/lib/uint8clampedarray.py
# class Uint8ClampedArray(array):
#     def __new__(cls, size=0):
#         return array.__new__(cls, 'B', [0] * size)
# 
#     def __getitem__(self, key):
#         return array.__getitem__(self, key)
# 
#     def __setitem__(self, key, value):
#         if value < 0:
#             value = 0
#         elif value > 255:
#             value = 255
#         return array.__setitem__(self, key, value)


# Path: tests/uint8clampedarray_test.py
import unittest
from canvas.lib.uint8clampedarray import Uint8ClampedArray

"""Tests for Canvas.CanvasRenderingContext2D.Uint8ClampedArray"""


class Uint8ClampedArrayTest(unittest.TestCase):
    """Tests for Uint8ClampedArray"""

    def setUp(self):
        self.clampedArray = Uint8ClampedArray(3)
        self.clampedArray[0] = -17 # Should get clamped at 0
        self.clampedArray[1] = 93  # Should remain at 93
        self.clampedArray[2] = 350 # Should get clamped at 255

    def test_is_instance(self):

        self.assertIsInstance(self.clampedArray, Uint8ClampedArray)