input: Write a function to create a reinforcement learning environment that simulates a game of tic-tac-toe in Python, including methods for initialization, resetting the game, taking actions, checking for a winner, and switching turns between players. The function should return the current state, reward, whether the game is done, and any additional info. Also, provide assert test cases to validate the functionality of the environment.
  assert TicTacToeEnv().check_winner() == None
  assert TicTacToeEnv().step(4)[0] == [' ', ' ', ' ', ' ', 'X', ' ', ' ', ' ', ' ']
  assert TicTacToeEnv().step(0)[3] == None
  env = TicTacToeEnv()
  env.step(0)
  assert env.step(1)[0] == ['X', 'O', ' ', ' ', ' ', ' ', ' ', ' ', ' ']
  assert env.step(8)[2] == True
output: def __init__(self):
      self.board = [' '] * 9
      self.current_player = 'X'
      self.done = False
  
  def reset(self):
      self.board = [' '] * 9
      self.current_player = 'X'
      self.done = False
      return self.board
  
  def step(self, action):
      if self.board[action] != ' ':
          return self.board, -1, self.done, None
      self.board[action] = self.current_player
      winner = self.check_winner()
      if winner:
          self.done = True
          return self.board, 1, self.done, winner
      if ' ' not in self.board:
          self.done = True
          return self.board, 0, self.done, None
      self.switch_turn()
      return self.board, 0, self.done, None
  
  def check_winner(self):
      lines = [
          [0, 1, 2], [3, 4, 5], [6, 7, 8],  # rows
          [0, 3, 6], [1, 4, 7], [2, 5, 8],  # columns
          [0, 4, 8], [2, 4, 6]              # diagonals
      ]
      for line in lines:
          if self.board[line[0]] == self.board[line[1]] == self.board[line[2]] != ' ':
              return self.board[line[0]]
      return None
  
  def switch_turn(self):
      self.current_player = 'O' if self.current_player == 'X' else 'X'